Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bgpd: Free memory in set_aspath_replace_access_list
Properly free the dynamically allocated memory held by `str` after its use. The change also maintains the return value of `nb_cli_apply_changes` by using 'ret' variable. The ASan leak log for reference: ``` *********************************************************************************** Address Sanitizer Error detected in bgp_set_aspath_replace.test_bgp_set_aspath_replace/r1.asan.bgpd.11586 ================================================================= ==11586==ERROR: LeakSanitizer: detected memory leaks Direct leak of 92 byte(s) in 3 object(s) allocated from: #0 0x7f4e2951db40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f4e28f19ea2 in qmalloc lib/memory.c:100 sonic-net#2 0x7f4e28edbb08 in frrstr_join lib/frrstr.c:89 sonic-net#3 0x7f4e28e9a601 in argv_concat lib/command.c:183 sonic-net#4 0x56519adf8413 in set_aspath_replace_access_list_magic bgpd/bgp_routemap.c:6174 sonic-net#5 0x56519adf8942 in set_aspath_replace_access_list bgpd/bgp_routemap_clippy.c:683 sonic-net#6 0x7f4e28e9d548 in cmd_execute_command_real lib/command.c:993 sonic-net#7 0x7f4e28e9da0c in cmd_execute_command lib/command.c:1051 sonic-net#8 0x7f4e28e9de8b in cmd_execute lib/command.c:1218 sonic-net#9 0x7f4e28fc4f1c in vty_command lib/vty.c:591 sonic-net#10 0x7f4e28fc53c7 in vty_execute lib/vty.c:1354 sonic-net#11 0x7f4e28fcdc8d in vtysh_read lib/vty.c:2362 sonic-net#12 0x7f4e28fb8c8b in event_call lib/event.c:1979 sonic-net#13 0x7f4e28efd445 in frr_run lib/libfrr.c:1213 sonic-net#14 0x56519ac85d81 in main bgpd/bgp_main.c:510 sonic-net#15 0x7f4e27f40c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 92 byte(s) leaked in 3 allocation(s). *********************************************************************************** *********************************************************************************** Address Sanitizer Error detected in bgp_set_aspath_exclude.test_bgp_set_aspath_exclude/r1.asan.bgpd.10385 ================================================================= ==10385==ERROR: LeakSanitizer: detected memory leaks Direct leak of 55 byte(s) in 2 object(s) allocated from: #0 0x7f6814fdab40 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.4+0xdeb40) sonic-net#1 0x7f68149d6ea2 in qmalloc lib/memory.c:100 sonic-net#2 0x7f6814998b08 in frrstr_join lib/frrstr.c:89 sonic-net#3 0x7f6814957601 in argv_concat lib/command.c:183 sonic-net#4 0x5570e05117a1 in set_aspath_exclude_access_list_magic bgpd/bgp_routemap.c:6327 sonic-net#5 0x5570e05119da in set_aspath_exclude_access_list bgpd/bgp_routemap_clippy.c:836 sonic-net#6 0x7f681495a548 in cmd_execute_command_real lib/command.c:993 sonic-net#7 0x7f681495aa0c in cmd_execute_command lib/command.c:1051 sonic-net#8 0x7f681495ae8b in cmd_execute lib/command.c:1218 sonic-net#9 0x7f6814a81f1c in vty_command lib/vty.c:591 sonic-net#10 0x7f6814a823c7 in vty_execute lib/vty.c:1354 sonic-net#11 0x7f6814a8ac8d in vtysh_read lib/vty.c:2362 sonic-net#12 0x7f6814a75c8b in event_call lib/event.c:1979 sonic-net#13 0x7f68149ba445 in frr_run lib/libfrr.c:1213 sonic-net#14 0x5570e03a0d81 in main bgpd/bgp_main.c:510 sonic-net#15 0x7f68139fdc86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86) SUMMARY: AddressSanitizer: 55 byte(s) leaked in 2 allocation(s). *********************************************************************************** ``` Signed-off-by: Keelan Cannoo <[email protected]>
- Loading branch information