From 5b4420298fa318534ff8271cfa82d913869b67e3 Mon Sep 17 00:00:00 2001 From: Alper Akcan Date: Mon, 5 Dec 2016 14:23:04 +0300 Subject: [PATCH] fix memory leak in cJSON_Duplicate --- cJSON.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 4e30384..bba72d8 100644 --- a/cJSON.c +++ b/cJSON.c @@ -2153,7 +2153,7 @@ cJSON *cJSON_Duplicate(const cJSON *item, cjbool recurse) } if (item->string) { - newitem->string = cJSON_strdup(item->string); + newitem->string = (item->type&cJSON_StringIsConst) ? item->string : cJSON_strdup(item->string); if (!newitem->string) { cJSON_Delete(newitem);