mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-14 16:04:49 +00:00
bgpd: simplify json create/free for memleak fix
Ticket: CM-25616 Signed-off-by: Don Slice <dslice@cumulusnetworks.com>
This commit is contained in:
parent
f86897b945
commit
3c13337daa
@ -7770,7 +7770,7 @@ static void bgp_show_bestpath_json(struct bgp *bgp, json_object *json)
|
|||||||
|
|
||||||
/* Show BGP peer's summary information. */
|
/* Show BGP peer's summary information. */
|
||||||
static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
|
static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
|
||||||
bool use_json, json_object *json)
|
bool use_json)
|
||||||
{
|
{
|
||||||
struct peer *peer;
|
struct peer *peer;
|
||||||
struct listnode *node, *nnode;
|
struct listnode *node, *nnode;
|
||||||
@ -7781,6 +7781,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
|
|||||||
int len;
|
int len;
|
||||||
int max_neighbor_width = 0;
|
int max_neighbor_width = 0;
|
||||||
int pfx_rcd_safi;
|
int pfx_rcd_safi;
|
||||||
|
json_object *json = NULL;
|
||||||
json_object *json_peer = NULL;
|
json_object *json_peer = NULL;
|
||||||
json_object *json_peers = NULL;
|
json_object *json_peers = NULL;
|
||||||
struct peer_af *paf;
|
struct peer_af *paf;
|
||||||
@ -7795,9 +7796,7 @@ static int bgp_show_summary(struct vty *vty, struct bgp *bgp, int afi, int safi,
|
|||||||
pfx_rcd_safi = safi;
|
pfx_rcd_safi = safi;
|
||||||
|
|
||||||
if (use_json) {
|
if (use_json) {
|
||||||
if (json == NULL)
|
json = json_object_new_object();
|
||||||
json = json_object_new_object();
|
|
||||||
|
|
||||||
json_peers = json_object_new_object();
|
json_peers = json_object_new_object();
|
||||||
} else {
|
} else {
|
||||||
/* Loop over all neighbors that will be displayed to determine
|
/* Loop over all neighbors that will be displayed to determine
|
||||||
@ -8209,7 +8208,6 @@ static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi,
|
|||||||
int safi_wildcard = (safi == SAFI_MAX);
|
int safi_wildcard = (safi == SAFI_MAX);
|
||||||
int is_wildcard = (afi_wildcard || safi_wildcard);
|
int is_wildcard = (afi_wildcard || safi_wildcard);
|
||||||
bool nbr_output = false;
|
bool nbr_output = false;
|
||||||
json_object *json = NULL;
|
|
||||||
|
|
||||||
if (use_json && is_wildcard)
|
if (use_json && is_wildcard)
|
||||||
vty_out(vty, "{\n");
|
vty_out(vty, "{\n");
|
||||||
@ -8222,9 +8220,6 @@ static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi,
|
|||||||
if (bgp_afi_safi_peer_exists(bgp, afi, safi)) {
|
if (bgp_afi_safi_peer_exists(bgp, afi, safi)) {
|
||||||
nbr_output = true;
|
nbr_output = true;
|
||||||
|
|
||||||
if (use_json)
|
|
||||||
json = json_object_new_object();
|
|
||||||
|
|
||||||
if (is_wildcard) {
|
if (is_wildcard) {
|
||||||
/*
|
/*
|
||||||
* So limit output to those afi/safi
|
* So limit output to those afi/safi
|
||||||
@ -8247,8 +8242,7 @@ static void bgp_show_summary_afi_safi(struct vty *vty, struct bgp *bgp, int afi,
|
|||||||
safi));
|
safi));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
bgp_show_summary(vty, bgp, afi, safi, use_json,
|
bgp_show_summary(vty, bgp, afi, safi, use_json);
|
||||||
json);
|
|
||||||
}
|
}
|
||||||
safi++;
|
safi++;
|
||||||
if (!safi_wildcard)
|
if (!safi_wildcard)
|
||||||
|
Loading…
Reference in New Issue
Block a user