bgpd: Prevent crash when displaying json of a vrf all command

When iterating over a `show ip bgp vrf all neighbors json` command
bgp is crashing.

The json variable was being double freed.  When freeing it, set it
to NULL and then check to make sure it exists before we free.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
Donald Sharp 2020-08-18 13:54:03 -04:00
parent f088c4e77d
commit 121067e9c5

View File

@ -12746,11 +12746,13 @@ static void bgp_show_all_instances_neighbors_vty(struct vty *vty,
use_json, json);
}
json_object_free(json);
json = NULL;
}
if (use_json) {
vty_out(vty, "}\n");
json_object_free(json);
if (json)
json_object_free(json);
}
else if (!nbr_output)
vty_out(vty, "%% BGP instance not found\n");