diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2018-04-06 17:53:03 +0200 |
---|---|---|
committer | Sebastien Douheret <sebastien.douheret@iot.bzh> | 2018-07-10 23:41:13 +0200 |
commit | 5e52e1099ceb4b1cb9cf95ce371fbd6742a9bb32 (patch) | |
tree | 29dbfdca77a141f782c2d7b723b9f151d31e2cc2 /src/harvester.c | |
parent | bdef812b7e2eb064b31d534440e0e4b8767429a7 (diff) |
Fix: alloc pb for post_data
Change-Id: Ic6fdeb8d3a3e2ca4aa33775fb6566df19407e1df
Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'src/harvester.c')
-rw-r--r-- | src/harvester.c | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/src/harvester.c b/src/harvester.c index 2120676..c3c1bc0 100644 --- a/src/harvester.c +++ b/src/harvester.c @@ -159,28 +159,25 @@ CURL *make_curl_write_post(const char *url, struct json_object *metric) const char *name = NULL, *source = NULL, *unit = NULL, - *identity = NULL, - **post_data; - char query[URL_MAXIMUM_LENGTH]; - memset(query, 0, URL_MAXIMUM_LENGTH); + *identity = NULL; - post_data = malloc(sizeof(*post_data)); + char *post_data[2], query[URL_MAXIMUM_LENGTH]; + bzero(query, URL_MAXIMUM_LENGTH); json_object *jv = NULL; uint64_t timestamp = 0; if(unpack_metric(metric, &name, &source, &unit, &identity, &jv, ×tamp)) { - AFB_ERROR("ERROR UNPACKING metric. %s", json_object_to_json_string(metric)); + AFB_ERROR("ERROR unpacking metric. %s", json_object_to_json_string(metric)); curl = NULL; } else { make_query(query, name, source, unit, identity, jv, timestamp); post_data[0] = query; post_data[1] = NULL; - curl = curl_wrap_prepare_post(url, NULL, 1, post_data); + curl = curl_wrap_prepare_post(url, NULL, 1, (const char * const*)post_data); } - free(post_data); return curl; } |