Commit 0e161499cc for frr
commit 0e161499ccdfd618a6e545d1fcfbddd3303c62c5
Author: Petr Vaganov <petrvaganoff@gmail.com>
Date: Tue Sep 8 21:40:50 2026 +0700
ospfd: fix memory leaks in ospf_router_info_show_info()
Dynamic memory, referenced by 'jpce' and 'jsr', is allocated at
ospf_ri.c:1658 by calling function 'json_object_new_object' and
lost at ospf_ri.c:1699. When condition json_object_object_length
is false - a memory leak is occurring.
Signed-off-by: Petr Vaganov <petrvaganoff@gmail.com>
diff --git a/ospfd/ospf_ri.c b/ospfd/ospf_ri.c
index 927a0e8f6f..e8e9c73eac 100644
--- a/ospfd/ospf_ri.c
+++ b/ospfd/ospf_ri.c
@@ -1693,8 +1693,13 @@ static void ospf_router_info_show_info(struct vty *vty,
if (json) {
if (json_object_object_length(jpce) > 1)
json_object_object_add(jri, "pceInformation", jpce);
+ else
+ json_object_free(jpce);
+
if (json_object_object_length(jsr) > 1)
json_object_object_add(jri, "segmentRouting", jsr);
+ else
+ json_object_free(jsr);
}
return;
}