mirror of
https://git.proxmox.com/git/mirror_frr
synced 2025-08-06 12:52:49 +00:00
bgpd: don't leak memory in community_regexp_include
Signed-off-by: Christian Franke <chris@opensourcerouting.org> Signed-off-by: Christian Franke <chris@opensourcerouting.org> Acked-by: Donald Sharp <sharpd@cumulusnetworks.com>
This commit is contained in:
parent
6e71194f11
commit
b84ee83b10
@ -403,17 +403,22 @@ community_str_get (struct community *com, int i)
|
|||||||
static int
|
static int
|
||||||
community_regexp_include (regex_t * reg, struct community *com, int i)
|
community_regexp_include (regex_t * reg, struct community *com, int i)
|
||||||
{
|
{
|
||||||
const char *str;
|
char *str;
|
||||||
|
int rv;
|
||||||
|
|
||||||
/* When there is no communities attribute it is treated as empty
|
/* When there is no communities attribute it is treated as empty
|
||||||
* string. */
|
* string. */
|
||||||
if (com == NULL || com->size == 0)
|
if (com == NULL || com->size == 0)
|
||||||
str = "";
|
str = XSTRDUP(MTYPE_COMMUNITY_STR, "");
|
||||||
else
|
else
|
||||||
str = community_str_get (com, i);
|
str = community_str_get (com, i);
|
||||||
|
|
||||||
/* Regular expression match. */
|
/* Regular expression match. */
|
||||||
if (regexec (reg, str, 0, NULL, 0) == 0)
|
rv = regexec (reg, str, 0, NULL, 0);
|
||||||
|
|
||||||
|
XFREE(MTYPE_COMMUNITY_STR, str);
|
||||||
|
|
||||||
|
if (rv == 0)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
/* No match. */
|
/* No match. */
|
||||||
|
Loading…
Reference in New Issue
Block a user