From: Florian Forster Date: Tue, 8 Dec 2015 12:14:47 +0000 (+0100) Subject: tail plugin: Fix memory leak. X-Git-Tag: collectd-5.5.1~13^2~11 X-Git-Url: https://git.octo.it/?p=collectd.git;a=commitdiff_plain;h=e3571ad6e1ada10fb7220193df57b7ef3b540ab1 tail plugin: Fix memory leak. CID: 38013 --- diff --git a/src/tail.c b/src/tail.c index 5b9dc539..72d97a38 100644 --- a/src/tail.c +++ b/src/tail.c @@ -223,7 +223,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) if (tm == NULL) { ERROR ("tail plugin: tail_match_create (%s) failed.", - ci->values[0].value.string); + ci->values[0].value.string); return (-1); } @@ -236,7 +236,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) { status = ctail_config_add_match (tm, plugin_instance, option); if (status == 0) - num_matches++; + num_matches++; /* Be mild with failed matches.. */ status = 0; } @@ -252,10 +252,12 @@ static int ctail_config_add_file (oconfig_item_t *ci) break; } /* for (i = 0; i < ci->children_num; i++) */ + sfree (plugin_instance); + if (num_matches == 0) { ERROR ("tail plugin: No (valid) matches found for file `%s'.", - ci->values[0].value.string); + ci->values[0].value.string); tail_match_destroy (tm); return (-1); } @@ -264,7 +266,7 @@ static int ctail_config_add_file (oconfig_item_t *ci) cu_tail_match_t **temp; temp = (cu_tail_match_t **) realloc (tail_match_list, - sizeof (cu_tail_match_t *) * (tail_match_list_num + 1)); + sizeof (cu_tail_match_t *) * (tail_match_list_num + 1)); if (temp == NULL) { ERROR ("tail plugin: realloc failed.");