diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 0beef97a0..80f807a1a 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -7638,9 +7638,11 @@ void bgp_aggregate_route(struct bgp *bgp, const struct prefix *p, afi_t afi, /* If the bgp instance is being deleted or self peer is deleted * then do not create aggregate route */ - if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS) - || (bgp->peer_self == NULL)) + if (CHECK_FLAG(bgp->flags, BGP_FLAG_DELETE_IN_PROGRESS) || + (bgp->peer_self == NULL)) { + bgp_aggregate_free(aggregate); return; + } /* Initialize and test routes for MED difference. */ if (aggregate->match_med)