From 702fd95af3408b157167bfd30728c66a212aeae7 Mon Sep 17 00:00:00 2001 From: Max Bruckner Date: Wed, 15 Feb 2017 20:45:23 +0100 Subject: [PATCH] fix #106: potentially invalid free in cJSON_AddItemToObject --- cJSON.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cJSON.c b/cJSON.c index 7c0d9f3..7d2c690 100644 --- a/cJSON.c +++ b/cJSON.c @@ -1771,7 +1771,7 @@ void cJSON_AddItemToObject(cJSON *object, const char *string, cJSON *item) } /* free old key and set new one */ - if (item->string) + if (!(item->type & cJSON_StringIsConst) && item->string) { cJSON_free(item->string); }