projects
/
collectd.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
perl plugin: Removed commented code
[collectd.git]
/
src
/
meta_data.c
diff --git
a/src/meta_data.c
b/src/meta_data.c
index
b502b37
..
0fc58ff
100644
(file)
--- a/
src/meta_data.c
+++ b/
src/meta_data.c
@@
-109,6
+109,8
@@
static meta_entry_t *md_entry_clone (const meta_entry_t *orig) /* {{{ */
return (NULL);
copy = md_entry_alloc (orig->key);
return (NULL);
copy = md_entry_alloc (orig->key);
+ if (copy == NULL)
+ return (NULL);
copy->type = orig->type;
if (copy->type == MD_TYPE_STRING)
copy->value.mv_string = strdup (orig->value.mv_string);
copy->type = orig->type;
if (copy->type == MD_TYPE_STRING)
copy->value.mv_string = strdup (orig->value.mv_string);
@@
-312,7
+314,13
@@
int meta_data_toc (meta_data_t *md, char ***toc) /* {{{ */
for (e = md->head; e != NULL; e = e->next)
++count;
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);
for (e = md->head; e != NULL; e = e->next)
(*toc)[i++] = strdup(e->key);
@@
-482,7
+490,7
@@
int meta_data_get_string (meta_data_t *md, /* {{{ */
if (e->type != MD_TYPE_STRING)
{
if (e->type != MD_TYPE_STRING)
{
- ERROR ("meta_data_get_s
igned_int
: Type mismatch for key `%s'", e->key);
+ ERROR ("meta_data_get_s
tring
: Type mismatch for key `%s'", e->key);
pthread_mutex_unlock (&md->lock);
return (-ENOENT);
}
pthread_mutex_unlock (&md->lock);
return (-ENOENT);
}