From fb8f41e455aec592eebcc4ccf4716e0c853133a6 Mon Sep 17 00:00:00 2001 From: "Raymond P. Burkholder" Date: Sun, 17 Dec 2017 11:53:34 -0400 Subject: [PATCH 1/2] bgpd: fixed '-Werror=maybe-uninitialized' warnings - used @sharpd's slack patch as a starting point - fixes compile time issue, but code path not tested Signed-off-by: Raymond P. Burkholder --- bgpd/bgp_evpn_vty.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index f473b4604a..4114c45221 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -414,9 +414,9 @@ static void show_vni_entry(struct hash_backet *backet, void *args[]) { struct vty *vty; json_object *json; - json_object *json_vni; - json_object *json_import_rtl; - json_object *json_export_rtl; + json_object *json_vni = NULL; + json_object *json_import_rtl = NULL; + json_object *json_export_rtl = NULL; struct bgpevpn *vpn = (struct bgpevpn *)backet->data; char buf1[10]; char buf2[RD_ADDRSTRLEN]; From 449feb8ef98347c28148af86dbcbaad35070a8ad Mon Sep 17 00:00:00 2001 From: Donald Sharp Date: Tue, 19 Dec 2017 08:20:30 -0500 Subject: [PATCH 2/2] bgpd: Fix double free The json code was freeing json_paths and then turning around and free'ing it again. Newer versions of json-c have started to assert this bad behavior. Signed-off-by: Donald Sharp --- bgpd/bgp_route.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index 2323572488..09759628cb 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -8396,6 +8396,7 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, vty_out(vty, "%s", json_object_to_json_string_ext(json_paths, JSON_C_TO_STRING_PRETTY)); json_object_free(json_paths); + json_paths = NULL; first = 0; } } @@ -8409,7 +8410,8 @@ static int bgp_show_table(struct vty *vty, struct bgp *bgp, safi_t safi, *total_cum = total_count; } if (use_json) { - json_object_free(json_paths); + if (json_paths) + json_object_free(json_paths); if (is_last) vty_out(vty, " } }\n"); else