From 5e52e1099ceb4b1cb9cf95ce371fbd6742a9bb32 Mon Sep 17 00:00:00 2001 From: Romain Forlot Date: Fri, 6 Apr 2018 17:53:03 +0200 Subject: Fix: alloc pb for post_data Change-Id: Ic6fdeb8d3a3e2ca4aa33775fb6566df19407e1df Signed-off-by: Romain Forlot --- src/harvester.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'src') 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; } -- cgit 1.2.3-korg