@@ -263,10 +263,12 @@ CJSON_PUBLIC(void) cJSON_Delete(cJSON *item)
263
263
if (!(item -> type & cJSON_IsReference ) && (item -> valuestring != NULL ))
264
264
{
265
265
global_hooks .deallocate (item -> valuestring );
266
+ item -> valuestring = NULL ;
266
267
}
267
268
if (!(item -> type & cJSON_StringIsConst ) && (item -> string != NULL ))
268
269
{
269
270
global_hooks .deallocate (item -> string );
271
+ item -> string = NULL ;
270
272
}
271
273
global_hooks .deallocate (item );
272
274
item = next ;
@@ -894,6 +896,7 @@ static cJSON_bool parse_string(cJSON * const item, parse_buffer * const input_bu
894
896
if (output != NULL )
895
897
{
896
898
input_buffer -> hooks .deallocate (output );
899
+ output = NULL ;
897
900
}
898
901
899
902
if (input_pointer != NULL )
@@ -1236,6 +1239,7 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
1236
1239
1237
1240
/* free the buffer */
1238
1241
hooks -> deallocate (buffer -> buffer );
1242
+ buffer -> buffer = NULL ;
1239
1243
}
1240
1244
1241
1245
return printed ;
@@ -1244,11 +1248,13 @@ static unsigned char *print(const cJSON * const item, cJSON_bool format, const i
1244
1248
if (buffer -> buffer != NULL )
1245
1249
{
1246
1250
hooks -> deallocate (buffer -> buffer );
1251
+ buffer -> buffer = NULL ;
1247
1252
}
1248
1253
1249
1254
if (printed != NULL )
1250
1255
{
1251
1256
hooks -> deallocate (printed );
1257
+ printed = NULL ;
1252
1258
}
1253
1259
1254
1260
return NULL ;
@@ -1289,6 +1295,7 @@ CJSON_PUBLIC(char *) cJSON_PrintBuffered(const cJSON *item, int prebuffer, cJSON
1289
1295
if (!print_value (item , & p ))
1290
1296
{
1291
1297
global_hooks .deallocate (p .buffer );
1298
+ p .buffer = NULL ;
1292
1299
return NULL ;
1293
1300
}
1294
1301
@@ -3132,4 +3139,5 @@ CJSON_PUBLIC(void *) cJSON_malloc(size_t size)
3132
3139
CJSON_PUBLIC (void ) cJSON_free (void * object )
3133
3140
{
3134
3141
global_hooks .deallocate (object );
3142
+ object = NULL ;
3135
3143
}
0 commit comments