From: Philippe Guibert Date: Wed, 1 Feb 2017 18:01:16 +0000 (+0100) Subject: bgpd: use XMALLOC for ESI handling X-Git-Tag: frr-3.0-branchpoint~29^2~17 X-Git-Url: https://git.puffer.fish/?a=commitdiff_plain;h=ffd28f0ec7818af78a550c853eb39763f8ab7438;p=matthieu%2Ffrr.git bgpd: use XMALLOC for ESI handling The memory allocation mecanism from frr is used. Signed-off-by: Philippe Guibert --- diff --git a/bgpd/bgp_attr_evpn.c b/bgpd/bgp_attr_evpn.c index 5969df211f..929b4c17c3 100644 --- a/bgpd/bgp_attr_evpn.c +++ b/bgpd/bgp_attr_evpn.c @@ -155,7 +155,7 @@ char *esi2str(struct eth_segment_id *id) return NULL; val = id->val; - ptr = (char *)malloc((ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char)); + ptr = (char *)XMALLOC(MTYPE_TMP, (ESI_LEN * 2 + ESI_LEN - 1 + 1) * sizeof(char)); snprintf(ptr, (ESI_LEN * 2 + ESI_LEN - 1 + 1), "%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x", diff --git a/bgpd/bgp_route.c b/bgpd/bgp_route.c index dd0abb675c..3d23fa4ca6 100644 --- a/bgpd/bgp_route.c +++ b/bgpd/bgp_route.c @@ -6611,7 +6611,7 @@ route_vty_out_overlay (struct vty *vty, struct prefix *p, struct eth_segment_id *id = &(attr->extra->evpn_overlay.eth_s_id); char *str = esi2str(id); vty_out (vty, "%s", str); - free(str); + XFREE (MTYPE_TMP, str); if (p->u.prefix_evpn.flags & IP_PREFIX_V4) { vty_out (vty, "/%s", inet_ntoa (attr->extra->evpn_overlay.gw_ip.ipv4)); @@ -10552,6 +10552,8 @@ bgp_config_write_network_evpn (struct vty *vty, struct bgp *bgp, vty_out (vty, "%s", VTY_NEWLINE); if (macrouter) XFREE (MTYPE_TMP, macrouter); + if (esi) + XFREE (MTYPE_TMP, esi); } return 0; }