diff options
author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2021-08-16 16:24:21 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-16 16:24:21 +0200 |
commit | 3af20fda0bc0eb0aecd497ba1412c39e97988c0a (patch) | |
tree | 530736bfbcfa903592953cd5f6c4cc0fbf8785db /bgpd/bgp_clist.c | |
parent | Merge pull request #9265 from ton31337/fix/extcommunity_lb_route-map_persistent (diff) | |
parent | bgpd: fix memory leaks in bgp_show_table (diff) | |
download | frr-3af20fda0bc0eb0aecd497ba1412c39e97988c0a.tar.xz frr-3af20fda0bc0eb0aecd497ba1412c39e97988c0a.zip |
Merge pull request #9369 from idryzhov/comm-alias-memleaks
bgpd: fix various memleaks when using community aliases
Diffstat (limited to 'bgpd/bgp_clist.c')
-rw-r--r-- | bgpd/bgp_clist.c | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c index d6ac88c09..33e3db2c1 100644 --- a/bgpd/bgp_clist.c +++ b/bgpd/bgp_clist.c @@ -549,6 +549,8 @@ static bool community_regexp_include(regex_t *reg, struct community *com, int i) static bool community_regexp_match(struct community *com, regex_t *reg) { const char *str; + char *regstr; + int rv; /* When there is no communities attribute it is treated as empty string. */ @@ -557,12 +559,14 @@ static bool community_regexp_match(struct community *com, regex_t *reg) else str = community_str(com, false); + regstr = bgp_alias2community_str(str); + /* Regular expression match. */ - if (regexec(reg, bgp_alias2community_str(str), 0, NULL, 0) == 0) - return true; + rv = regexec(reg, regstr, 0, NULL, 0); - /* No match. */ - return false; + XFREE(MTYPE_TMP, regstr); + + return rv == 0; } static char *lcommunity_str_get(struct lcommunity *lcom, int i) @@ -619,6 +623,8 @@ static bool lcommunity_regexp_include(regex_t *reg, struct lcommunity *lcom, static bool lcommunity_regexp_match(struct lcommunity *com, regex_t *reg) { const char *str; + char *regstr; + int rv; /* When there is no communities attribute it is treated as empty string. */ @@ -627,12 +633,14 @@ static bool lcommunity_regexp_match(struct lcommunity *com, regex_t *reg) else str = lcommunity_str(com, false); + regstr = bgp_alias2community_str(str); + /* Regular expression match. */ - if (regexec(reg, bgp_alias2community_str(str), 0, NULL, 0) == 0) - return true; + rv = regexec(reg, regstr, 0, NULL, 0); - /* No match. */ - return false; + XFREE(MTYPE_TMP, regstr); + + return rv == 0; } |