From 444438552db9fa889fb0b15e8c68ed1804312c1f Mon Sep 17 00:00:00 2001 From: Sebastian Harl Date: Sat, 4 Jun 2016 17:58:23 +0200 Subject: [PATCH] utils_vl_lookup: Free regexen when destroying class lists. Else, we'll leak any memory used by the regex. --- src/utils_vl_lookup.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) 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); -- 2.30.2