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 <vic.lan@pica8.com>
This commit is contained in:
anlan_cs 2022-10-31 22:09:15 -04:00
parent a5dac02901
commit ed8862ad30

View File

@ -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;