X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fcurl_json.c;h=79ae68fced0293ef392fa777385d022d3e9fb0e0;hb=36ee20dc97d0e0a5483892667f5d032618e18f10;hp=4fa6f33bc6ce1e55c213fbcfbe8bbbdd4cc75f07;hpb=1ebf2f31bd2e080e6f42de640f0a3899a61501c0;p=collectd.git diff --git a/src/curl_json.c b/src/curl_json.c index 4fa6f33b..79ae68fc 100644 --- a/src/curl_json.c +++ b/src/curl_json.c @@ -446,16 +446,19 @@ static c_avl_tree_t *cj_avl_create(void) static int cj_config_append_string (const char *name, struct curl_slist **dest, /* {{{ */ oconfig_item_t *ci) { + struct curl_slist *temp = NULL; if ((ci->values_num != 1) || (ci->values[0].type != OCONFIG_TYPE_STRING)) { WARNING ("curl_json plugin: `%s' needs exactly one string argument.", name); return (-1); } - *dest = curl_slist_append(*dest, ci->values[0].value.string); - if (*dest == NULL) + temp = curl_slist_append(*dest, ci->values[0].value.string); + if (temp == NULL) return (-1); + *dest = temp; + return (0); } /* }}} int cj_config_append_string */ @@ -474,13 +477,12 @@ static int cj_config_add_key (cj_t *db, /* {{{ */ return (-1); } - key = malloc (sizeof (*key)); + key = calloc (1, sizeof (*key)); if (key == NULL) { - ERROR ("curl_json plugin: malloc failed."); + ERROR ("curl_json plugin: calloc failed."); return (-1); } - memset (key, 0, sizeof (*key)); key->magic = CJ_KEY_MAGIC; if (strcasecmp ("Key", ci->key) == 0) @@ -667,13 +669,12 @@ static int cj_config_add_url (oconfig_item_t *ci) /* {{{ */ return (-1); } - db = malloc (sizeof (*db)); + db = calloc (1, sizeof (*db)); if (db == NULL) { - ERROR ("curl_json plugin: malloc failed."); + ERROR ("curl_json plugin: calloc failed."); return (-1); } - memset (db, 0, sizeof (*db)); db->timeout = -1;