From: Nigel Kukard Date: Wed, 30 Aug 2017 07:37:19 +0000 (+0000) Subject: bgpd: Fixed potential memory leak if additive is false X-Git-Tag: frr-4.0-dev~348^2~7 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=4265a53eba952d1108b58327558ad59d023ab186;p=mirror%2Ffrr.git bgpd: Fixed potential memory leak if additive is false The else portion of the IF dups the lc, but doesn't free old Signed-off-by: Nigel Kukard --- diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c index f5ee4fe897..f76110b7ea 100644 --- a/bgpd/bgp_routemap.c +++ b/bgpd/bgp_routemap.c @@ -1611,18 +1611,19 @@ static route_map_result_t route_set_lcommunity(void *rule, merge = lcommunity_merge(lcommunity_dup(old), rcs->lcom); - /* HACK: if the old large-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) - lcommunity_free(&old); new = lcommunity_uniq_sort(merge); lcommunity_free(&merge); } else new = lcommunity_dup(rcs->lcom); + /* HACK: if the old large-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 && old->refcnt == 0) + lcommunity_free(&old); + /* will be intern()'d or attr_flush()'d by bgp_update_main() */ attr->lcommunity = new;