mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-12 05:34:41 +00:00
bgpd: Prevent ecommunity_ecom2str memory leak
We were allocating but never freeing memory associated with the ecommunity_ecom2str allocation. Signed-off-by: Donald Sharp <sharpd@nvidia.com>
This commit is contained in:
parent
b9d4546253
commit
6a37bfb7e5
@ -903,7 +903,7 @@ char *ecommunity_ecom2str(struct ecommunity *ecom, int format, int filter)
|
||||
int str_size;
|
||||
char *str_buf;
|
||||
|
||||
if (ecom->size == 0)
|
||||
if (!ecom || ecom->size == 0)
|
||||
return XCALLOC(MTYPE_ECOMMUNITY_STR, 1);
|
||||
|
||||
/* ecom strlen + space + null term */
|
||||
|
@ -1760,19 +1760,26 @@ void vrf_import_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp,
|
||||
|
||||
if (debug) {
|
||||
const char *from_name;
|
||||
char *ecom1, *ecom2;
|
||||
|
||||
from_name = from_bgp->name ? from_bgp->name :
|
||||
VRF_DEFAULT_NAME;
|
||||
zlog_debug("%s from %s to %s first_export %u import-rt %s export-rt %s",
|
||||
__func__, from_name, export_name, first_export,
|
||||
to_bgp->vpn_policy[afi].rtlist[idir] ?
|
||||
(ecommunity_ecom2str(to_bgp->vpn_policy[afi].
|
||||
rtlist[idir],
|
||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0)) : " ",
|
||||
to_bgp->vpn_policy[afi].rtlist[edir] ?
|
||||
(ecommunity_ecom2str(to_bgp->vpn_policy[afi].
|
||||
rtlist[edir],
|
||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0)) : " ");
|
||||
|
||||
ecom1 = ecommunity_ecom2str(
|
||||
to_bgp->vpn_policy[afi].rtlist[idir],
|
||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||
|
||||
ecom2 = ecommunity_ecom2str(
|
||||
to_bgp->vpn_policy[afi].rtlist[edir],
|
||||
ECOMMUNITY_FORMAT_ROUTE_MAP, 0);
|
||||
|
||||
zlog_debug(
|
||||
"%s from %s to %s first_export %u import-rt %s export-rt %s",
|
||||
__func__, from_name, export_name, first_export, ecom1,
|
||||
ecom2);
|
||||
|
||||
ecommunity_strfree(&ecom1);
|
||||
ecommunity_strfree(&ecom2);
|
||||
}
|
||||
|
||||
/* Does "import_vrf" first need to export its routes or that
|
||||
|
Loading…
Reference in New Issue
Block a user