You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I can still print the string even after freeing the object (line 3)?
To check if obj is really freed, I tried adding an object and i'm hitting seg fault which proved object is freed. So, why json_str is still valid after object freed?
The text was updated successfully, but these errors were encountered:
Looks like a side-effect of free. free(ptr) doesn't necessarily erase memory. So the contents of the memory might still be valid until the block is reassigned.
const char * json_str = json_object_to_json_string(jsonobj);
json_object_put(jsonobj);
printf("%s\n", json_str);
json_object_object_add(jsonobj, "key", json_object_new_int64(value)); //
I can still print the string even after freeing the object (line 3)?
To check if obj is really freed, I tried adding an object and i'm hitting seg fault which proved object is freed. So, why json_str is still valid after object freed?
The text was updated successfully, but these errors were encountered: