ospfd: Fix memory leak after cleaning cleaning up interfaceIp JSON field

```
=================================================================
==6717==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 1008 byte(s) in 14 object(s) allocated from:
    0 0x7f9ea0dc7d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    1 0x7f9ea034d51f in json_object_new_object (/lib/x86_64-linux-gnu/libjson-c.so.3+0x351f)
    2 0x564b56d0fed6 in show_ip_ospf_interface_common ospfd/ospf_vty.c:4011
    3 0x564b56d1068c in show_ip_ospf_interface ospfd/ospf_vty.c:4285
    4 0x7f9ea06fe1c0 in cmd_execute_command_real lib/command.c:1002
    5 0x7f9ea06fe684 in cmd_execute_command lib/command.c:1060
    6 0x7f9ea06feb03 in cmd_execute lib/command.c:1227
    7 0x7f9ea08415b2 in vty_command lib/vty.c:616
    8 0x7f9ea0841a5d in vty_execute lib/vty.c:1379
    9 0x7f9ea084b367 in vtysh_read lib/vty.c:2374
    10 0x7f9ea08350cd in event_call lib/event.c:2011
    11 0x7f9ea0764386 in frr_run lib/libfrr.c:1217
    12 0x564b56c25b18 in main ospfd/ospf_main.c:295
    13 0x7f9e9fd5bc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

Indirect leak of 7168 byte(s) in 14 object(s) allocated from:
    0 0x7f9ea0dc7d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    1 0x7f9ea0350fa4 in lh_table_new (/lib/x86_64-linux-gnu/libjson-c.so.3+0x6fa4)

Indirect leak of 1232 byte(s) in 14 object(s) allocated from:
    0 0x7f9ea0dc7d28 in __interceptor_calloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xded28)
    1 0x7f9ea0350f82 in lh_table_new (/lib/x86_64-linux-gnu/libjson-c.so.3+0x6f82)

SUMMARY: AddressSanitizer: 9408 byte(s) leaked in 42 allocation(s).
***********************************************************************************
```

Fixes: e24ff4c275 ("ospfd: Drop `interfaceIp` from `show ip ospf neigh json")

Signed-off-by: Donatas Abraitis <donatas@opensourcerouting.org>
This commit is contained in:
Donatas Abraitis 2024-06-12 16:28:38 +03:00
parent 3cc01bb00b
commit e8f5caa21b

View File

@ -3576,7 +3576,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
struct route_node *rn;
uint32_t bandwidth = ifp->bandwidth ? ifp->bandwidth : ifp->speed;
struct ospf_if_params *params;
json_object *json_oi = NULL;
/* Is interface up? */
if (use_json) {
@ -3633,12 +3632,9 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
if (oi == NULL)
continue;
if (use_json)
json_oi = json_object_new_object();
if (CHECK_FLAG(oi->connected->flags, ZEBRA_IFA_UNNUMBERED)) {
if (use_json)
json_object_boolean_true_add(json_oi,
json_object_boolean_true_add(json_interface_sub,
"ifUnnumbered");
else
vty_out(vty, " This interface is UNNUMBERED,");
@ -3932,8 +3928,6 @@ static void show_ip_ospf_interface_sub(struct vty *vty, struct ospf *ospf,
/* OSPF Authentication information */
ospf_interface_auth_show(vty, oi, json_interface_sub, use_json);
ospf_interface_auth_show(vty, oi, json_oi, use_json);
/* Point-to-Multipoint Interface options. */
if (oi->type == OSPF_IFTYPE_POINTOMULTIPOINT) {
if (use_json)