From 2dfc9167abcfa42a2d3c6725336cce4eb82e9613 Mon Sep 17 00:00:00 2001 From: Alexander Sohn Date: Tue, 11 Jul 2023 16:21:57 +0200 Subject: [PATCH] bgpd: Fix memory leak by moving allocation of json object Signed-off-by: Alexander Sohn --- bgpd/bgp_route.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 0b821acfae..4d63356e3d 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -13836,11 +13836,11 @@ static int bgp_table_stats_single(struct vty *vty, struct bgp *bgp, afi_t afi, json_bitlen = json_object_new_array(); for (i = 0; i <= bitlen; i++) { - struct json_object *ind_bit = json_object_new_object(); - if (!ts.prefix_len_count[i]) continue; + struct json_object *ind_bit = json_object_new_object(); + snprintf(temp_buf, sizeof(temp_buf), "%u", i); json_object_int_add(ind_bit, temp_buf, ts.prefix_len_count[i]); -- 2.39.5