From 8bd0d3b1db2eeaeaf9c6f5eedc9b7779233ad8df Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Mon, 13 Dec 2021 17:21:56 -0300 Subject: [PATCH] bgpd: fix aggregate route AS Path attribute Always free the locally allocated attribute not the one we are using for return. This fixes a memory leak and a crash when AS Path is set with route-map. Signed-off-by: Rafael Zalamena --- bgpd/bgp_attr.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_attr.c b/bgpd/bgp_attr.c index 7de7a6628f..c765be432c 100644 --- a/bgpd/bgp_attr.c +++ b/bgpd/bgp_attr.c @@ -1073,7 +1073,9 @@ struct attr *bgp_attr_aggregate_intern( new = bgp_attr_intern(&attr); } - aspath_unintern(&new->aspath); + /* Always release the 'intern()'ed AS Path. */ + aspath_unintern(&attr.aspath); + return new; }