diff --git a/bgpd/bgp_aspath.c b/bgpd/bgp_aspath.c index 12bd45d9e359..1c128b611d12 100644 --- a/bgpd/bgp_aspath.c +++ b/bgpd/bgp_aspath.c @@ -1289,6 +1289,9 @@ struct aspath *aspath_replace_specific_asn(struct aspath *aspath, seg = seg->next; } + if (!aspath->refcnt) + aspath_free(aspath); + aspath_str_update(new, false); return new; } @@ -1337,6 +1340,9 @@ struct aspath *aspath_replace_private_asns(struct aspath *aspath, as_t asn, seg = seg->next; } + if (!aspath->refcnt) + aspath_free(aspath); + aspath_str_update(new, false); return new; } @@ -1407,7 +1413,8 @@ struct aspath *aspath_remove_private_asns(struct aspath *aspath, as_t peer_asn) last_new_seg = new_seg; seg = seg->next; } - + if (!aspath->refcnt) + aspath_free(aspath); aspath_str_update(new, false); return new; }