From: Florian Forster Date: Fri, 16 Dec 2016 17:38:34 +0000 (+0100) Subject: set target: Avoid casting negative int to size_t. X-Git-Tag: collectd-5.7.1~12^2 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=55c1bf4105459ff39906f108aa8ad3f99cc0504b;p=collectd.git set target: Avoid casting negative int to size_t. CID: 157643 --- diff --git a/src/target_set.c b/src/target_set.c index 7d54c93b..a40273c0 100644 --- a/src/target_set.c +++ b/src/target_set.c @@ -183,8 +183,11 @@ static void ts_subst(char *dest, size_t size, const char *string, /* {{{ */ REPLACE_FIELD("%{type_instance}", vl->type_instance); if (vl->meta != NULL) { - char **meta_toc; + char **meta_toc = NULL; int meta_entries = meta_data_toc(vl->meta, &meta_toc); + if (meta_entries <= 0) + return; + for (int i = 0; i < meta_entries; i++) { char meta_name[DATA_MAX_NAME_LEN]; char *value_str;