Selaa lähdekoodia

fix #106: potentially invalid free in cJSON_AddItemToObject

Max Bruckner 8 vuotta sitten
vanhempi
commit
702fd95af3
1 muutettua tiedostoa jossa 1 lisäystä ja 1 poistoa
  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);
     }