From: Quentin Young Date: Fri, 9 Jun 2017 20:18:56 +0000 (+0000) Subject: bgpd: fix memleak with 'show ip bgp vrf ...' X-Git-Tag: reindent-master-before~77^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=47332bd02b8c9adc278b1e8f72b8823d4117c230;p=mirror%2Ffrr.git bgpd: fix memleak with 'show ip bgp vrf ...' Signed-off-by: Quentin Young --- diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c index ec53e19330..f5f538de95 100644 --- a/bgpd/bgp_vty.c +++ b/bgpd/bgp_vty.c @@ -9375,9 +9375,6 @@ bgp_show_neighbor_vty (struct vty *vty, const char *name, union sockunion su; json_object *json = NULL; - if (use_json) - json = json_object_new_object(); - if (name) { if (strmatch(name, "all")) @@ -9392,6 +9389,7 @@ bgp_show_neighbor_vty (struct vty *vty, const char *name, { if (use_json) { + json = json_object_new_object(); json_object_boolean_true_add(json, "bgpNoSuchInstance"); vty_out (vty, "%s%s", json_object_to_json_string_ext(json, JSON_C_TO_STRING_PRETTY), VTY_NEWLINE); json_object_free(json); @@ -9410,6 +9408,7 @@ bgp_show_neighbor_vty (struct vty *vty, const char *name, if (bgp) { + json = json_object_new_object(); if (ip_str) { ret = str2sockunion (ip_str, &su); @@ -9422,6 +9421,7 @@ bgp_show_neighbor_vty (struct vty *vty, const char *name, { bgp_show_neighbor (vty, bgp, type, NULL, NULL, use_json, json); } + json_object_free (json); } return CMD_SUCCESS;