bgpd: Fix memory leak of some "show ip bgp neighbor" commands
sockunion_str2su() use is prone to memory leaks. Remove it's use all over
the code.
At least these commands leaked a sockunion union:
- show ip bgp vpnv4 ... routes
- show ip bgp ... received prefix-filter
Signed-off-by: Jorge Boncompte [DTI2] <jorge@dti2.net>
Signed-off-by: David Lamparter <equinox@diac24.net>
diff --git a/bgpd/bgp_vty.c b/bgpd/bgp_vty.c
index bba1c7d..03746bd 100644
--- a/bgpd/bgp_vty.c
+++ b/bgpd/bgp_vty.c
@@ -2943,7 +2943,6 @@
const char *source_str)
{
struct peer *peer;
- union sockunion *su;
peer = peer_and_group_lookup_vty (vty, peer_str);
if (! peer)
@@ -2951,12 +2950,11 @@
if (source_str)
{
- su = sockunion_str2su (source_str);
- if (su)
- {
- peer_update_source_addr_set (peer, su);
- sockunion_free (su);
- }
+ union sockunion su;
+ int ret = str2sockunion (source_str, &su);
+
+ if (ret == 0)
+ peer_update_source_addr_set (peer, &su);
else
peer_update_source_if_set (peer, source_str);
}