From: anlan_cs Date: Tue, 1 Nov 2022 02:09:15 +0000 (-0400) Subject: bgpd: avoid possible memleak X-Git-Tag: base_8.5~270^2 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=ed8862ad30a57f7abb99e8cf6cdf6b3fab4d9cfb;p=mirror%2Ffrr.git bgpd: avoid possible memleak In the case of without ':' in `ecom_str`, memleak on this `ecom_str` will occur. Just free `ecom_str` for this case. Signed-off-by: anlan_cs --- diff --git a/bgpd/bgp_evpn_vty.c b/bgpd/bgp_evpn_vty.c index c0ad72dc33..7dbfdc60d4 100644 --- a/bgpd/bgp_evpn_vty.c +++ b/bgpd/bgp_evpn_vty.c @@ -6639,9 +6639,10 @@ void bgp_config_write_evpn_info(struct vty *vty, struct bgp *bgp, afi_t afi, char *vni_str = NULL; vni_str = strchr(ecom_str, ':'); - - if (!vni_str) - continue; /* This should never happen */ + if (!vni_str) { + XFREE(MTYPE_ECOMMUNITY_STR, ecom_str); + continue; + } /* Move pointer to vni */ vni_str += 1;