From: Michael Lambert Date: Mon, 13 Sep 2010 15:48:11 +0000 (-0400) Subject: bgpd: fix memory leak when deleting a community X-Git-Tag: frr-2.0-rc1~2073 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=604a9b43dd68a087ca5a4ac2cae19eb17591ba5f;p=matthieu%2Ffrr.git bgpd: fix memory leak when deleting a community * bgp_routemap.c: (route_set_community_delete) When deleting a community in a route-map the old community was being orphaned. Like the description of the same code in route_set_community, this is a hack, not a true fix. --- diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index 81ff48dbd6..255b25aedf 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1393,6 +1393,13 @@ route_set_community_delete (void *rule, struct prefix *prefix, new = community_uniq_sort (merge); community_free (merge); + /* HACK: if the old community is not intern'd, + * we should free it here, or all reference to it may be lost. + * Really need to cleanup attribute caching sometime. + */ + if (old->refcnt == 0) + community_free (old); + if (new->size == 0) { binfo->attr->community = NULL;