From ce4e451c5b86d3f79c88283e2a7425ce32e9df1b Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 13 Aug 2024 08:49:01 -0400 Subject: [PATCH] bgpd: Free up non-freed json memory on function return json_peers is allocated in the above if statement block for json but is not freed in this code path. Noticed by running Address Sanitizer. Signed-off-by: Donald Sharp --- bgpd/bgp_vty.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index a3180fd707b9..43e267c5e871 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -12046,6 +12046,8 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi, if (show_failed && !failed_count) { if (use_json) { + json_object_free(json_peers); + json_object_int_add(json, "failedPeersCount", 0); json_object_int_add(json, "dynamicPeers", dn_count); json_object_int_add(json, "totalPeers", count);