From: Sebastian Harl Date: Sat, 4 Jun 2016 15:58:23 +0000 (+0200) Subject: utils_vl_lookup: Free regexen when destroying class lists. X-Git-Tag: collectd-5.6.0~243^2~6 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=444438552db9fa889fb0b15e8c68ed1804312c1f;p=collectd.git utils_vl_lookup: Free regexen when destroying class lists. Else, we'll leak any memory used by the regex. --- diff --git a/src/utils_vl_lookup.c b/src/utils_vl_lookup.c index a0237841..8a2e5671 100644 --- a/src/utils_vl_lookup.c +++ b/src/utils_vl_lookup.c @@ -495,6 +495,21 @@ static void lu_destroy_user_class_list (lookup_t *obj, /* {{{ */ obj->cb_free_class (user_class_list->entry.user_class); user_class_list->entry.user_class = NULL; +#define CLEAR_FIELD(field) do { \ + if (user_class_list->entry.match.field.is_regex) { \ + regfree (&user_class_list->entry.match.field.regex); \ + user_class_list->entry.match.field.is_regex = 0; \ + } \ +} while (0) + + CLEAR_FIELD (host); + CLEAR_FIELD (plugin); + CLEAR_FIELD (plugin_instance); + CLEAR_FIELD (type); + CLEAR_FIELD (type_instance); + +#undef CLEAR_FIELD + lu_destroy_user_obj (obj, user_class_list->entry.user_obj_list); user_class_list->entry.user_obj_list = NULL; pthread_mutex_destroy (&user_class_list->entry.lock);