]> git.puffer.fish Git - matthieu/frr.git/commitdiff
ospfd: Fix memory leaks w/ `show ip ospf int X json` commands
authorDonald Sharp <sharpd@nvidia.com>
Thu, 4 May 2023 16:53:42 +0000 (12:53 -0400)
committerMergify <37929162+mergify[bot]@users.noreply.github.com>
Fri, 5 May 2023 12:14:57 +0000 (12:14 +0000)
FRR has a memory leak in the case when int X does not
exist and a memory leak when int X does exist.  Fix
these

Fixes: #13434
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
(cherry picked from commit 74e21732db129f7287d5ab227e45f305c5dbf34e)

ospfd/ospf_vty.c

index b9f154ad039ca6971b51c0730a0ca003ae315d6e..ed3d09b1bd6e51eb6dfe5e6765a2011eba28dbe0 100644 (file)
@@ -3945,16 +3945,15 @@ static int show_ip_ospf_interface_common(struct vty *vty, struct ospf *ospf,
                /* Interface name is specified. */
                ifp = if_lookup_by_name(intf_name, ospf->vrf_id);
                if (ifp == NULL) {
-                       if (use_json)
+                       if (use_json) {
                                json_object_boolean_true_add(json_vrf,
                                                             "noSuchIface");
-                       else
+                               json_object_free(json_interface);
+                       } else
                                vty_out(vty, "No such interface name\n");
                } else {
-                       if (use_json) {
+                       if (use_json)
                                json_interface_sub = json_object_new_object();
-                               json_interface = json_object_new_object();
-                       }
 
                        show_ip_ospf_interface_sub(
                                vty, ospf, ifp, json_interface_sub, use_json);