diff options
| author | Russ White <russ@riw.us> | 2020-01-28 10:06:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-01-28 10:06:03 -0500 |
| commit | f96ed15ba334f6ee2b4ca91d52931561b0305df1 (patch) | |
| tree | e35b5465ba1a13f5f83453a7c11501de670d9ed8 | |
| parent | 73c7d6e06631838b45a22e086f7223b0d0333c83 (diff) | |
| parent | 24882500ff0f6c84afd73916ffb2b69a3a76008f (diff) | |
Merge pull request #5731 from chiragshah6/mdev
bgpd: fix memory leak in evpn json outpus II
| -rw-r--r-- | bgpd/bgp_evpn_vty.c | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 125ed61e74..44a884830a 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -687,14 +687,22 @@ static void show_esi_routes(struct bgp *bgp, add_prefix_to_json = 1; } - if (json && add_prefix_to_json) { - json_object_string_add(json_prefix, "prefix", - prefix_str); - json_object_int_add(json_prefix, "prefixLen", - rn->p.prefixlen); - json_object_object_add(json_prefix, "paths", - json_paths); - json_object_object_add(json, prefix_str, json_prefix); + if (json) { + if (add_prefix_to_json) { + json_object_string_add(json_prefix, "prefix", + prefix_str); + json_object_int_add(json_prefix, "prefixLen", + rn->p.prefixlen); + json_object_object_add(json_prefix, "paths", + json_paths); + json_object_object_add(json, prefix_str, + json_prefix); + } else { + json_object_free(json_paths); + json_object_free(json_prefix); + json_paths = NULL; + json_prefix = NULL; + } } } @@ -786,14 +794,22 @@ static void show_vni_routes(struct bgp *bgp, struct bgpevpn *vpn, int type, add_prefix_to_json = 1; } - if (json && add_prefix_to_json) { - json_object_string_add(json_prefix, "prefix", - prefix_str); - json_object_int_add(json_prefix, "prefixLen", - rn->p.prefixlen); - json_object_object_add(json_prefix, "paths", - json_paths); - json_object_object_add(json, prefix_str, json_prefix); + if (json) { + if (add_prefix_to_json) { + json_object_string_add(json_prefix, "prefix", + prefix_str); + json_object_int_add(json_prefix, "prefixLen", + rn->p.prefixlen); + json_object_object_add(json_prefix, "paths", + json_paths); + json_object_object_add(json, prefix_str, + json_prefix); + } else { + json_object_free(json_paths); + json_object_free(json_prefix); + json_paths = NULL; + json_prefix = NULL; + } } } |
