]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: Fix memory leak by moving allocation of json object 13983/head
authorAlexander Sohn <github@asohn.de>
Tue, 11 Jul 2023 14:21:57 +0000 (16:21 +0200)
committerAlexander Sohn <github@asohn.de>
Tue, 11 Jul 2023 14:21:57 +0000 (16:21 +0200)
Signed-off-by: Alexander Sohn <github@asohn.de>
bgpd/bgp_route.c

index 0b821acfae56a2084429df598121084afbb77def..4d63356e3d7c330a0e9b51a53656780802268b23 100644 (file)
@@ -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]);