From: paul Date: Wed, 14 May 2003 18:29:13 +0000 (+0000) Subject: From: Gilad Arnold X-Git-Tag: frr-2.0-rc1~4072 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=a0f6acd8a49906399e2ac73fde6406da552b2443;p=mirror%2Ffrr.git From: Gilad Arnold Subject: [zebra 19080] suspected memory leakage upon static route deletion upon deletion of a static route entry, at the end of zebra/zebra_rib.c/static_delete_ipv4(), there's a call to XFREE to deallocate the 'struct static_ipv4'. However, in the case of a static with ifname as nexthop (type==STATIC_IPV4_IFNAME), this struct holds a pointer to a dynamically allocated ifname string buffer (si->gate.ifname, see its allocation within static_add_ipv4() using XSTRDUP). IMO, the attached patch is required. Notes: the same applies to IPv6 statics as well (fix included in patch); and, I admit I haven't yet tested that, but it seems simple enough to be working... ;-> --- diff --git a/zebra/zebra_rib.c b/zebra/zebra_rib.c index 0f7ccebc52..f3b9fd6509 100644 --- a/zebra/zebra_rib.c +++ b/zebra/zebra_rib.c @@ -1554,6 +1554,8 @@ static_delete_ipv4 (struct prefix *p, struct in_addr *gate, char *ifname, si->next->prev = si->prev; /* Free static route configuration. */ + if (ifname) + XFREE (0, si->gate.ifname); XFREE (MTYPE_STATIC_IPV4, si); return 1; @@ -2078,6 +2080,8 @@ static_delete_ipv6 (struct prefix *p, u_char type, struct in6_addr *gate, si->next->prev = si->prev; /* Free static route configuration. */ + if (ifname) + XFREE (0, si->ifname); XFREE (MTYPE_STATIC_IPV6, si); return 1;