From: Donald Sharp Date: Fri, 6 Aug 2021 20:00:32 +0000 (-0400) Subject: zebra: Prevent memory leak if route is rejected early X-Git-Tag: base_8.1~220^2~1 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=f94a7703c0725766f7dd91931718d3869ed28116;p=mirror%2Ffrr.git zebra: Prevent memory leak if route is rejected early When receiving a route via zapi, if the route is rejected there exists a code path where we would not free the corresponding re created. Signed-off-by: Donald Sharp --- diff --git a/zebra/zapi_msg.c b/zebra/zapi_msg.c index 27fb5d7c22..08ad390d32 100644 --- a/zebra/zapi_msg.c +++ b/zebra/zapi_msg.c @@ -2110,6 +2110,13 @@ static void zread_route_add(ZAPI_HANDLER_ARGS) ret = rib_add_multipath_nhe(afi, api.safi, &api.prefix, src_p, re, &nhe); + /* + * rib_add_multipath_nhe only fails in a couple spots + * and in those spots we have not freed memory + */ + if (ret == -1) + XFREE(MTYPE_RE, re); + /* At this point, these allocations are not needed: 're' has been * retained or freed, and if 're' still exists, it is using * a reference to a shared group object.