X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=src%2Fmeta_data.c;h=48dcabcec884d8bed391ece4eb184ee3aed9f700;hb=ef4a3db895a0aba7107c0f1c6c2ef2a7f128aaf8;hp=ea98ba94abf44670583ab47601e39ce6a0f68394;hpb=d19bcbf5c310f3656503e64ba26829256112ded4;p=collectd.git diff --git a/src/meta_data.c b/src/meta_data.c index ea98ba94..48dcabce 100644 --- a/src/meta_data.c +++ b/src/meta_data.c @@ -313,7 +313,13 @@ int meta_data_toc (meta_data_t *md, char ***toc) /* {{{ */ for (e = md->head; e != NULL; e = e->next) ++count; - *toc = malloc(count * sizeof(**toc)); + if (count == 0) + { + pthread_mutex_unlock (&md->lock); + return (count); + } + + *toc = calloc(count, sizeof(**toc)); for (e = md->head; e != NULL; e = e->next) (*toc)[i++] = strdup(e->key); @@ -483,7 +489,7 @@ int meta_data_get_string (meta_data_t *md, /* {{{ */ if (e->type != MD_TYPE_STRING) { - ERROR ("meta_data_get_signed_int: Type mismatch for key `%s'", e->key); + ERROR ("meta_data_get_string: Type mismatch for key `%s'", e->key); pthread_mutex_unlock (&md->lock); return (-ENOENT); }