Explorar o código

fix #106: potentially invalid free in cJSON_AddItemToObject

Max Bruckner %!s(int64=8) %!d(string=hai) anos
pai
achega
702fd95af3
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  1. 1 1
      cJSON.c

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