From a0ff4a1f01ecda2b80be76a9e2888d86d831b22c Mon Sep 17 00:00:00 2001 From: simon987 Date: Mon, 17 Aug 2020 18:13:41 -0400 Subject: [PATCH] Fix heap buffer overflow warning --- src/index/elastic.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/index/elastic.c b/src/index/elastic.c index 68e8542..1fea575 100644 --- a/src/index/elastic.c +++ b/src/index/elastic.c @@ -415,7 +415,11 @@ cJSON *elastic_get_document(const char *uuid_str) { response_t *r = web_get(url, 3); cJSON *json = NULL; if (r->status_code == 200) { - json = cJSON_Parse(r->body); + char *tmp = malloc(r->size + 1); + memcpy(tmp, r->body, r->size); + *(tmp + r->size) = '\0'; + json = cJSON_Parse(tmp); + free(tmp); } free_response(r); return json;