X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fplugin.c;h=a5ae97b6fd825f857580e548ddaac79117f6474a;hb=f9666730f0bde464c27b794810b74eed7741e073;hp=6139baf0de05a2145ac5020d73d2bf64ef2814ae;hpb=704675554b87f98a65af6a35dcf62c58ce4a5272;p=collectd.git diff --git a/src/plugin.c b/src/plugin.c index 6139baf0..a5ae97b6 100644 --- a/src/plugin.c +++ b/src/plugin.c @@ -1136,6 +1136,8 @@ int plugin_dispatch_values (value_list_t *vl) data_set_t *ds; + int free_meta_data = 0; + if ((vl == NULL) || (vl->type[0] == 0) || (vl->values == NULL) || (vl->values_len < 1)) { @@ -1143,6 +1145,12 @@ int plugin_dispatch_values (value_list_t *vl) return (-1); } + /* Free meta data only if the calling function didn't specify any. In + * this case matches and targets may add some and the calling function + * may not expect (and therefore free) that data. */ + if (vl->meta == NULL) + free_meta_data = 1; + if (list_write == NULL) c_complain_once (LOG_WARNING, &no_write_complaint, "plugin_dispatch_values: No write callback has been " @@ -1283,6 +1291,12 @@ int plugin_dispatch_values (value_list_t *vl) vl->values_len = saved_values_len; } + if ((free_meta_data != 0) && (vl->meta != NULL)) + { + meta_data_destroy (vl->meta); + vl->meta = NULL; + } + return (0); } /* int plugin_dispatch_values */