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); }