projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
7acb8df
)
src/meta_data.c: If the meta_data_t is empty, avoid calling malloc(0).
author
Florian Forster
<octo@collectd.org>
Tue, 2 Sep 2014 17:50:47 +0000
(19:50 +0200)
committer
Florian Forster
<octo@collectd.org>
Tue, 2 Sep 2014 17:50:47 +0000
(19:50 +0200)
src/meta_data.c
patch
|
blob
|
history
diff --git
a/src/meta_data.c
b/src/meta_data.c
index
ea98ba9
..
1b58735
100644
(file)
--- 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);