bgpd: fix a memleak on "set community none"
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: David Lamparter <equinox@opensourcerouting.org>
diff --git a/bgpd/bgp_routemap.c b/bgpd/bgp_routemap.c
index f220400..40f2076 100644
--- a/bgpd/bgp_routemap.c
+++ b/bgpd/bgp_routemap.c
@@ -1347,6 +1347,9 @@
{
attr->flag &= ~(ATTR_FLAG_BIT (BGP_ATTR_COMMUNITIES));
attr->community = NULL;
+ /* See the longer comment down below. */
+ if (old && old->refcnt == 0)
+ community_free(old);
return RMAP_OKAY;
}