From e1c1ac10e1ace7757632ff4f872127cb7afeb4f9 Mon Sep 17 00:00:00 2001 From: Krzysztof Matczak Date: Fri, 24 Feb 2017 09:38:14 +0000 Subject: [PATCH] fix for memory leak in utils_match.c Change-Id: I058afae8c0a99115bda70e125840fc6bd224b358 Signed-off-by: Krzysztof Matczak --- src/daemon/utils_match.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/daemon/utils_match.c b/src/daemon/utils_match.c index cd815825..be5dfd6e 100644 --- a/src/daemon/utils_match.c +++ b/src/daemon/utils_match.c @@ -35,6 +35,7 @@ #define UTILS_MATCH_FLAGS_FREE_USER_DATA 0x01 #define UTILS_MATCH_FLAGS_EXCLUDE_REGEX 0x02 +#define UTILS_MATCH_FLAGS_REGEX 0x04 struct cu_match_s { regex_t regex; @@ -218,6 +219,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); @@ -271,9 +273,12 @@ void match_destroy(cu_match_t *obj) { if (obj == NULL) return; - if (obj->flags & UTILS_MATCH_FLAGS_FREE_USER_DATA) { + if (obj->flags & UTILS_MATCH_FLAGS_FREE_USER_DATA) sfree(obj->user_data); - } + if (obj->flags & UTILS_MATCH_FLAGS_REGEX) + regfree(&obj->regex); + if (obj->flags & UTILS_MATCH_FLAGS_EXCLUDE_REGEX) + regfree(&obj->excluderegex); sfree(obj); } /* void match_destroy */ -- 2.30.2