fix json_object_put() to return 1 for freed scalars and empty containers

The iterative rewrite in 17328a67 made json_object_put() return 0 for freed scalars, strings and empty containers, contradicting the documented contract in json_object.h. Distinguish "freed" from "still referenced" in _json_object_put_maybe_free() and add regression tests.
This commit is contained in:
Arran Cudbard-Bell
2026-07-14 10:28:04 -04:00
parent e65444a258
commit 69be99ef8e
3 changed files with 70 additions and 16 deletions
+7
View File
@@ -1,3 +1,10 @@
Parsed depth 100000 string to json_object: yes
Freed json_object
in user_delete, userdata_val=1
put(empty object) returned 1
put(empty array) returned 1
put(string) returned 1
put(int) returned 1
put(non-empty object) returned 1
put(still-referenced object) returned 0
put(last reference) returned 1