]> git.proxmox.com Git - mirror_frr.git/commit
bgpd: Fix memory leak show ip bgp json
authorroot <root@dev.vmware.com>
Wed, 22 Aug 2018 23:08:26 +0000 (16:08 -0700)
committerroot <root@dev.vmware.com>
Wed, 22 Aug 2018 23:22:17 +0000 (16:22 -0700)
commitb2a9fc6b2362fba18324f9e2ce2c9b04bae262b1
tree7105e2b8df8b324a14d81e5802486a7474a62934
parent1f063a699b8979d1808673341c5365fed01e9b4a
bgpd: Fix memory leak show ip bgp json

Root Cause: In the function bgp_show_table(), we are creating a
json object and a json array with the same name as “json_paths”.
First it will create a json object variable "json_paths" pointing
to the memory allocated for the json object. Then it will create
a json array for each bap node rn (if rn->info is available) with
the same name as json_paths. Because of this, json_paths which was
pointing to the memory allocated for the json object earlier, now
will be overwritten with the memory allocated for the json array.
As per the existing code, at the end of each iteration loop of bgp
node, it will deallocate the memory used by the json array and
assigned NULL to the variable json_paths. Since we don’t have the
pointer pointing to the memory allocated for json object, will be
not able to de-allocate the memory, which is a memory leak here.

Fix: Removing this json object since it is never getting used in
this function.

Testing:  Reproduced the memory leak with valgrind.
With the fix, memory leak gets resolved and checked with valgrind.

Signed-off-by: Sarita Patra saritap@vmware.com
bgpd/bgp_route.c