diff options
| author | Quentin Young <qlyoung@users.noreply.github.com> | 2020-05-05 17:39:28 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-05-05 17:39:28 -0400 |
| commit | 794c2b2d738b5f9066b47a8a1142a318e51a4d07 (patch) | |
| tree | d6f671bb9e77588d367e772e3f6a21dea6ced9c1 | |
| parent | d973526821e6af5380d41ef7b2ff09f976b70fbc (diff) | |
| parent | 2c15754ea3327009c9c81650a0fea6f071fd0889 (diff) | |
Merge pull request #6350 from pureport/fix/bgp_double_community_free
bgpd: Check to ensure community attributes exist before freeing them
| -rw-r--r-- | bgpd/bgp_community.c | 3 | ||||
| -rw-r--r-- | bgpd/bgp_ecommunity.c | 3 | ||||
| -rw-r--r-- | bgpd/bgp_lcommunity.c | 3 |
3 files changed, 9 insertions, 0 deletions
diff --git a/bgpd/bgp_community.c b/bgpd/bgp_community.c index 30de84c878..0d60fbf479 100644 --- a/bgpd/bgp_community.c +++ b/bgpd/bgp_community.c @@ -40,6 +40,9 @@ static struct community *community_new(void) /* Free communities value. */ void community_free(struct community **com) { + if (!(*com)) + return; + XFREE(MTYPE_COMMUNITY_VAL, (*com)->val); XFREE(MTYPE_COMMUNITY_STR, (*com)->str); diff --git a/bgpd/bgp_ecommunity.c b/bgpd/bgp_ecommunity.c index 062a6477fa..d13da74b04 100644 --- a/bgpd/bgp_ecommunity.c +++ b/bgpd/bgp_ecommunity.c @@ -59,6 +59,9 @@ void ecommunity_strfree(char **s) /* Allocate ecommunities. */ void ecommunity_free(struct ecommunity **ecom) { + if (!(*ecom)) + return; + XFREE(MTYPE_ECOMMUNITY_VAL, (*ecom)->val); XFREE(MTYPE_ECOMMUNITY_STR, (*ecom)->str); XFREE(MTYPE_ECOMMUNITY, *ecom); diff --git a/bgpd/bgp_lcommunity.c b/bgpd/bgp_lcommunity.c index f47ae91663..5900fcf862 100644 --- a/bgpd/bgp_lcommunity.c +++ b/bgpd/bgp_lcommunity.c @@ -44,6 +44,9 @@ static struct lcommunity *lcommunity_new(void) /* Allocate lcommunities. */ void lcommunity_free(struct lcommunity **lcom) { + if (!(*lcom)) + return; + XFREE(MTYPE_LCOMMUNITY_VAL, (*lcom)->val); XFREE(MTYPE_LCOMMUNITY_STR, (*lcom)->str); if ((*lcom)->json) |
