Issue #934: Also set _userdata=NULL in _json_object_maybe_free() so json_object_put doesn't try to use it as a _delete_parent value.

Update the test_deep_nesting test output.
This commit is contained in:
Eric Hawicz
2026-07-04 11:39:02 -04:00
parent e00697585b
commit 0c3a5a1994
2 changed files with 6 additions and 2 deletions
+5 -2
View File
@@ -304,6 +304,8 @@ static inline int _json_object_put_maybe_free(struct json_object *jso, int free_
if (jso->_user_delete) if (jso->_user_delete)
jso->_user_delete(jso, jso->_userdata); jso->_user_delete(jso, jso->_userdata);
jso->_user_delete = NULL; jso->_user_delete = NULL;
jso->_userdata = NULL; // aka _delete_parent, but json_object_put() will
// have already grabbed it if it needs it.
switch (jso->o_type) switch (jso->o_type)
{ {
@@ -435,10 +437,11 @@ int json_object_put(struct json_object *jso)
// All slots are cleared, now pop back up to the parent // All slots are cleared, now pop back up to the parent
{ {
json_object *parent = jso->_delete_parent;
int rc;
// jso is a child that's already been detached from its parent // jso is a child that's already been detached from its parent
// so we need to actually free it now // so we need to actually free it now
// Be sure to grab _delete_parent *before* freeing jso.
json_object *parent = jso->_delete_parent;
int rc;
assert(jso->_ref_count == 0); assert(jso->_ref_count == 0);
jso->_ref_count++; // We're the exclusive owner of jso, non-atomic add is ok. jso->_ref_count++; // We're the exclusive owner of jso, non-atomic add is ok.
// Note: the call must not be inside assert(), or it gets // Note: the call must not be inside assert(), or it gets
+1
View File
@@ -1,2 +1,3 @@
Parsed depth 100000 string to json_object: yes Parsed depth 100000 string to json_object: yes
Freed json_object Freed json_object
in user_delete, userdata_val=1