mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-07 01:40:16 +00:00
ospfd: Fix some json mem leaks and some issues
a) if show_function happened to be NULL we would leak json memory b) json_lsa_type was being allocated but only used in the default case, leaking memory c) json output would sometimes produce text output and that is incorrect Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
f147ca860b
commit
f9f19fef9d
@ -6614,14 +6614,17 @@ static void show_lsa_detail_proc(struct vty *vty, struct route_table *rt,
|
|||||||
route_lock_node(start);
|
route_lock_node(start);
|
||||||
for (rn = start; rn; rn = route_next_until(rn, start))
|
for (rn = start; rn; rn = route_next_until(rn, start))
|
||||||
if ((lsa = rn->info)) {
|
if ((lsa = rn->info)) {
|
||||||
if (json) {
|
if (show_function[lsa->data->type] != NULL) {
|
||||||
json_lsa = json_object_new_object();
|
if (json) {
|
||||||
json_object_array_add(json, json_lsa);
|
json_lsa =
|
||||||
}
|
json_object_new_object();
|
||||||
|
json_object_array_add(json,
|
||||||
|
json_lsa);
|
||||||
|
}
|
||||||
|
|
||||||
if (show_function[lsa->data->type] != NULL)
|
|
||||||
show_function[lsa->data->type](
|
show_function[lsa->data->type](
|
||||||
vty, lsa, json_lsa);
|
vty, lsa, json_lsa);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
route_unlock_node(start);
|
route_unlock_node(start);
|
||||||
}
|
}
|
||||||
@ -6640,9 +6643,6 @@ static void show_lsa_detail(struct vty *vty, struct ospf *ospf, int type,
|
|||||||
json_object *json_areas = NULL;
|
json_object *json_areas = NULL;
|
||||||
json_object *json_lsa_array = NULL;
|
json_object *json_lsa_array = NULL;
|
||||||
|
|
||||||
if (json)
|
|
||||||
json_lsa_type = json_object_new_object();
|
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case OSPF_AS_EXTERNAL_LSA:
|
case OSPF_AS_EXTERNAL_LSA:
|
||||||
case OSPF_OPAQUE_AS_LSA:
|
case OSPF_OPAQUE_AS_LSA:
|
||||||
@ -6685,6 +6685,7 @@ static void show_lsa_detail(struct vty *vty, struct ospf *ospf, int type,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (json) {
|
if (json) {
|
||||||
|
json_lsa_type = json_object_new_object();
|
||||||
json_object_object_add(json_lsa_type, "areas",
|
json_object_object_add(json_lsa_type, "areas",
|
||||||
json_areas);
|
json_areas);
|
||||||
json_object_object_add(json,
|
json_object_object_add(json,
|
||||||
@ -7158,6 +7159,9 @@ DEFUN (show_ip_ospf_database_max,
|
|||||||
vty_out(vty,
|
vty_out(vty,
|
||||||
"%% OSPF is not enabled in vrf %s\n",
|
"%% OSPF is not enabled in vrf %s\n",
|
||||||
vrf_name);
|
vrf_name);
|
||||||
|
if (uj)
|
||||||
|
json_object_free(json);
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
ret = (show_ip_ospf_database_common(
|
ret = (show_ip_ospf_database_common(
|
||||||
@ -7169,6 +7173,9 @@ DEFUN (show_ip_ospf_database_max,
|
|||||||
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
ospf = ospf_lookup_by_vrf_id(VRF_DEFAULT);
|
||||||
if (ospf == NULL || !ospf->oi_running) {
|
if (ospf == NULL || !ospf->oi_running) {
|
||||||
vty_out(vty, "%% OSPF is not enabled in vrf default\n");
|
vty_out(vty, "%% OSPF is not enabled in vrf default\n");
|
||||||
|
if (uj)
|
||||||
|
json_object_free(json);
|
||||||
|
|
||||||
return CMD_SUCCESS;
|
return CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user