diff --git a/cJSON.c b/cJSON.c index 7c0d9f37209b769f932ac3142cb3f6b81ec46e7c..7d2c690421e710e23de94e9c623838cc6e1dde0c 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); }