From ed8862ad30a57f7abb99e8cf6cdf6b3fab4d9cfb Mon Sep 17 00:00:00 2001 From: anlan_cs Date: Mon, 31 Oct 2022 22:09:15 -0400 Subject: [PATCH] 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 --- bgpd/bgp_evpn_vty.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) 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; -- 2.39.5