]> git.puffer.fish Git - mirror/frr.git/commitdiff
bgpd: fix memleak with 'show ip bgp vrf ...' 699/head
authorQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 9 Jun 2017 20:18:56 +0000 (20:18 +0000)
committerQuentin Young <qlyoung@cumulusnetworks.com>
Fri, 9 Jun 2017 20:18:56 +0000 (20:18 +0000)
Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
bgpd/bgp_vty.c

index ec53e19330158640085375b5dda21f9f943301a9..f5f538de95ae7d9346dfcfb18de6d841f0fdbd1e 100644 (file)
@@ -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;