]> git.proxmox.com Git - mirror_frr.git/blobdiff - bgpd/bgp_aspath.c
bgpd: Free previously dup'ed aspath attribute for aggregate routes
[mirror_frr.git] / bgpd / bgp_aspath.c
index 2cc7e46573a46fbf9be837104756c824176a7a6d..55be70c3ffefe070d1bbcf2c0ab1e4cd8df56fb1 100644 (file)
@@ -2157,11 +2157,15 @@ static void bgp_aggr_aspath_prepare(struct hash_bucket *hb, void *arg)
 {
        struct aspath *hb_aspath = hb->data;
        struct aspath **aggr_aspath = arg;
+       struct aspath *aspath = NULL;
 
-       if (*aggr_aspath)
-               *aggr_aspath = aspath_aggregate(*aggr_aspath, hb_aspath);
-       else
+       if (*aggr_aspath) {
+               aspath = aspath_aggregate(*aggr_aspath, hb_aspath);
+               aspath_free(*aggr_aspath);
+               *aggr_aspath = aspath;
+       } else {
                *aggr_aspath = aspath_dup(hb_aspath);
+       }
 }
 
 void bgp_aggr_aspath_remove(void *arg)