X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Futils_match.c;h=11b3f74f9394c0cb2727e1d47f1d31c49b10fe33;hb=004074af297a219208fa9e903db8c5dcdd7e1950;hp=2e487b5933fc0b32525ea000fabca09e45b65772;hpb=1584297665665f900011297f1ae0e29ecf9ce379;p=collectd.git diff --git a/src/utils_match.c b/src/utils_match.c index 2e487b59..11b3f74f 100644 --- a/src/utils_match.c +++ b/src/utils_match.c @@ -34,6 +34,7 @@ #include #define UTILS_MATCH_FLAGS_EXCLUDE_REGEX 0x02 +#define UTILS_MATCH_FLAGS_REGEX 0x04 struct cu_match_s { regex_t regex; @@ -234,6 +235,7 @@ match_create_callback(const char *regex, const char *excluderegex, sfree(obj); return (NULL); } + obj->flags |= UTILS_MATCH_FLAGS_REGEX; if (excluderegex && strcmp(excluderegex, "") != 0) { status = regcomp(&obj->excluderegex, excluderegex, REG_EXTENDED); @@ -301,6 +303,10 @@ void match_destroy(cu_match_t *obj) { if (obj == NULL) return; + if (obj->flags & UTILS_MATCH_FLAGS_REGEX) + regfree(&obj->regex); + if (obj->flags & UTILS_MATCH_FLAGS_EXCLUDE_REGEX) + regfree(&obj->excluderegex); if ((obj->user_data != NULL) && (obj->free != NULL)) (*obj->free)(obj->user_data);