summaryrefslogtreecommitdiff
path: root/bgpd/bgp_clist.c
diff options
context:
space:
mode:
Diffstat (limited to 'bgpd/bgp_clist.c')
-rw-r--r--bgpd/bgp_clist.c24
1 files changed, 16 insertions, 8 deletions
diff --git a/bgpd/bgp_clist.c b/bgpd/bgp_clist.c
index d6ac88c09b..33e3db2c16 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;
}