bgpd: fix memory leaks in show commands
sockunion_str2su allocates a struct sockunion that used to be leaked
in the show commands. Use str2sockunion and keep the information
on the stack instead.
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Signed-off-by: Christian Franke <chris@opensourcerouting.org>
Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
Signed-off-by: Philippe Guibert <philippe.guibert@6wind.com>
diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c
index 19c6429..ec2f967 100644
--- a/bgpd/bgp_route.c
+++ b/bgpd/bgp_route.c
@@ -9428,7 +9428,7 @@
struct community *com;
struct buffer *b;
struct bgp *bgp;
- int i;
+ int i, rv;
char *str;
int first = 0;
@@ -9479,9 +9479,11 @@
return CMD_WARNING;
}
- return bgp_show (vty, bgp, afi, safi,
- (exact ? bgp_show_type_community_exact :
- bgp_show_type_community), com);
+ rv = bgp_show (vty, bgp, afi, safi,
+ (exact ? bgp_show_type_community_exact :
+ bgp_show_type_community), com);
+ community_free(com);
+ return rv;
}
DEFUN (show_ip_bgp_community,