From: Florian Forster Date: Fri, 19 Jun 2015 08:54:02 +0000 (+0200) Subject: src/utils_ignorelist.c: Fix memory leak. X-Git-Tag: collectd-5.5.1~68^2~22 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=f3f57e2ea492880d236edbff39632bf8be911262;p=collectd.git src/utils_ignorelist.c: Fix memory leak. Turns out, regfree(3) cleans up the memory allocated by regcomp(3), but not the pointer itself. --- diff --git a/src/utils_ignorelist.c b/src/utils_ignorelist.c index de42d0fa..b8169ff6 100644 --- a/src/utils_ignorelist.c +++ b/src/utils_ignorelist.c @@ -131,6 +131,7 @@ static int ignorelist_append_regex(ignorelist_t *il, const char *entry) if (errsize) sfree (regerr); regfree (regtemp); + sfree (regtemp); return (1); } DEBUG("regex compiled: %s - %i", entry, rcompile); @@ -140,6 +141,7 @@ static int ignorelist_append_regex(ignorelist_t *il, const char *entry) { ERROR ("cannot allocate new config entry"); regfree (regtemp); + sfree (regtemp); return (1); } memset (new, '\0', sizeof(ignorelist_item_t)); @@ -248,6 +250,7 @@ void ignorelist_free (ignorelist_t *il) if (this->rmatch != NULL) { regfree (this->rmatch); + sfree (this->rmatch); this->rmatch = NULL; } #endif