]> git.puffer.fish Git - mirror/frr.git/commit
bgpd: Fix memory leak 13925/head
authorKeelan10 <keelan.cannoo@icloud.com>
Tue, 4 Jul 2023 09:35:10 +0000 (13:35 +0400)
committerKeelan10 <keelan.cannoo@icloud.com>
Wed, 5 Jul 2023 18:17:48 +0000 (22:17 +0400)
commit9d659b167d280177c40a347c8acb0d79509e805a
tree7bf9975735d843bbe6b355326f33b97d02b997ac
parentd6caf0dbd7bc9c516d178430ca571ac0c94df84d
bgpd: Fix memory leak

The `bgp_vrf->vrf_prd_pretty` string was not properly freed, leading to a memory leak.
This commit resolves the memory leak by freeing the memory allocated for `bgp_vrf->vrf_prd_pretty` before returning from the function.

The ASan leak log for reference:
```
***********************************************************************************
Address Sanitizer Error detected in evpn_type5_test_topo1.test_evpn_type5_topo1/e1.asan.bgpd.17689

=================================================================
==17689==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 15 byte(s) in 1 object(s) allocated from:
    #0 0x7fdd94fc0538 in strdup (/usr/lib/x86_64-linux-gnu/libasan.so.4+0x77538)
    #1 0x55e28d9c4c6c in qstrdup lib/memory.c:117
    #2 0x55e28d6c0d27 in evpn_configure_vrf_rd bgpd/bgp_evpn_vty.c:2297
    #3 0x55e28d6c0d27 in bgp_evpn_vrf_rd bgpd/bgp_evpn_vty.c:6271
    #4 0x55e28d94c155 in cmd_execute_command_real lib/command.c:994
    #5 0x55e28d94c622 in cmd_execute_command lib/command.c:1053
    #6 0x55e28d94ca99 in cmd_execute lib/command.c:1221
    #7 0x55e28da6d7d4 in vty_command lib/vty.c:591
    #8 0x55e28da6dc6e in vty_execute lib/vty.c:1354
    #9 0x55e28da7644d in vtysh_read lib/vty.c:2362
    #10 0x55e28da616e2 in event_call lib/event.c:1995
    #11 0x55e28d9a7a65 in frr_run lib/libfrr.c:1213
    #12 0x55e28d63ef00 in main bgpd/bgp_main.c:505
    #13 0x7fdd93883c86 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x21c86)

SUMMARY: AddressSanitizer: 15 byte(s) leaked in 1 allocation(s).
***********************************************************************************
```

Signed-off-by: Keelan Cannoo <keelan.cannoo@icloud.com>
bgpd/bgp_evpn_vty.c