diff options
author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2020-01-27 08:12:44 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-27 08:12:44 +0100 |
commit | 3812117bfcc154ee2dc50dc4cc2512545c872013 (patch) | |
tree | 56afd996521f464672c94bdd29bbd04f5429d259 | |
parent | Merge pull request #5620 from qlyoung/fix-zebra-vrf-label-afi-check (diff) | |
parent | bgpd: fix memory leak in evpn json outputs (diff) | |
download | frr-3812117bfcc154ee2dc50dc4cc2512545c872013.tar.xz frr-3812117bfcc154ee2dc50dc4cc2512545c872013.zip |
Merge pull request #5727 from chiragshah6/mdev
bgpd: fix memory leak in evpn json outputs
-rw-r--r-- | bgpd/bgp_evpn_vty.c | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index 3049a00ce..125ed61e7 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -2579,18 +2579,29 @@ static void evpn_show_route_rd(struct vty *vty, struct bgp *bgp, add_rd_to_json = 1; } - if (json && add_prefix_to_json) { - json_object_object_add(json_prefix, "paths", - json_paths); - json_object_object_add(json_rd, prefix_str, - json_prefix); + if (json) { + if (add_prefix_to_json) { + json_object_object_add(json_prefix, "paths", + json_paths); + json_object_object_add(json_rd, prefix_str, + json_prefix); + } else { + json_object_free(json_paths); + json_object_free(json_prefix); + json_paths = NULL; + json_prefix = NULL; + } } } - if (json && add_rd_to_json) - json_object_object_add(json, rd_str, json_rd); - if (json) { + if (add_rd_to_json) + json_object_object_add(json, rd_str, json_rd); + else { + json_object_free(json_rd); + json_rd = NULL; + } + json_object_int_add(json, "numPrefix", prefix_cnt); json_object_int_add(json, "numPaths", path_cnt); } else { @@ -2732,16 +2743,31 @@ static void evpn_show_all_routes(struct vty *vty, struct bgp *bgp, int type, json_path); } - if (json && add_prefix_to_json) { - json_object_object_add(json_prefix, "paths", - json_paths); - json_object_object_add(json_rd, prefix_str, - json_prefix); + if (json) { + if (add_prefix_to_json) { + json_object_object_add(json_prefix, + "paths", + json_paths); + json_object_object_add(json_rd, + prefix_str, + json_prefix); + } else { + json_object_free(json_prefix); + json_object_free(json_paths); + json_prefix = NULL; + json_paths = NULL; + } } } - if (json && add_rd_to_json) - json_object_object_add(json, rd_str, json_rd); + if (json) { + if (add_rd_to_json) + json_object_object_add(json, rd_str, json_rd); + else { + json_object_free(json_rd); + json_rd = NULL; + } + } } if (json) { |