diff options
| author | Mark Stapp <mjs@voltanet.io> | 2020-11-18 17:31:03 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-11-18 17:31:03 -0500 |
| commit | abed797ef5c4ff35538d1b418b34cce7d79b008b (patch) | |
| tree | 454093cf5ba291919b6ce323e502bb371ccf189a | |
| parent | 95bd143ec329cd822fda2d4661bc933d6e87b478 (diff) | |
| parent | 6a37bfb7e50b86df9b5c6cce38c6a86fffb90ed9 (diff) | |
Merge pull request #7556 from donaldsharp/memory_shenanigans
Memory shenanigans
| -rw-r--r-- | bgpd/bgp_ecommunity.c | 2 | ||||
| -rw-r--r-- | bgpd/bgp_mplsvpn.c | 32 | ||||
| -rw-r--r-- | ospf6d/ospf6_snmp.c | 3 | ||||
| -rw-r--r-- | pimd/pim_cmd.c | 1 |
4 files changed, 25 insertions, 13 deletions
diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 74cbf3a80a..43bfb3e2bc 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -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 */ diff --git a/bgpd/bgp_mplsvpn.c b/bgpd/bgp_mplsvpn.c index 662c5da414..3bc4c03233 100644 --- a/bgpd/bgp_mplsvpn.c +++ b/bgpd/bgp_mplsvpn.c @@ -1703,6 +1703,8 @@ void vrf_import_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp, if (!is_inst_match) listnode_add(to_bgp->vpn_policy[afi].import_vrf, vname); + else + XFREE(MTYPE_TMP, vname); /* Check if the source vrf already exports to any vrf, * first time export requires to setup auto derived RD/RT values. @@ -1725,6 +1727,9 @@ void vrf_import_from_vrf(struct bgp *to_bgp, struct bgp *from_bgp, if (!is_inst_match) listnode_add(from_bgp->vpn_policy[afi].export_vrf, vname); + else + XFREE(MTYPE_TMP, vname); + /* Update import RT for current VRF using export RT of the VRF we're * importing from. First though, make sure "import_vrf" has that * set. @@ -1755,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 diff --git a/ospf6d/ospf6_snmp.c b/ospf6d/ospf6_snmp.c index 3aeba3b609..1836dc2068 100644 --- a/ospf6d/ospf6_snmp.c +++ b/ospf6d/ospf6_snmp.c @@ -1267,8 +1267,6 @@ static uint8_t *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length, } else { /* We build a sorted list of interfaces */ ifslist = list_new(); - if (!ifslist) - return NULL; ifslist->cmp = (int (*)(void *, void *))if_icmp_func; FOR_ALL_INTERFACES (vrf, iif) listnode_add_sort(ifslist, iif); @@ -1296,6 +1294,7 @@ static uint8_t *ospfv3NbrEntry(struct variable *v, oid *name, size_t *length, } list_delete_all_node(ifslist); + list_delete(&ifslist); } if (!oi || !on) diff --git a/pimd/pim_cmd.c b/pimd/pim_cmd.c index 2a7ff4e7f8..adf6faef57 100644 --- a/pimd/pim_cmd.c +++ b/pimd/pim_cmd.c @@ -6109,6 +6109,7 @@ static void show_mroute(struct pim_instance *pim, struct vty *vty, json_object_object_add(json_oil, out_ifname, json_ifp_out); } else { + proto[0] = '\0'; if (c_oil->oif_flags[oif_vif_index] & PIM_OIF_FLAG_PROTO_PIM) { strlcpy(proto, "PIM", sizeof(proto)); |
