cpython/Lib/test/test_json
Ramin Farajpour Cami 8a466fa3d9
gh-145244: Fix use-after-free on borrowed dict key in json encoder (GH-145245)
In encoder_encode_key_value(), key is a borrowed reference from
PyDict_Next(). If the default callback mutates or clears the dict,
key becomes a dangling pointer. The error path then calls
_PyErr_FormatNote("%R", key) on freed memory.

Fix by holding strong references to key and value unconditionally
during encoding, not just in the free-threading build.

Co-authored-by: Peter Bierma <zintensitydev@gmail.com>
2026-04-11 22:26:36 +00:00
..
__init__.py
__main__.py
test_decode.py gh-146440: Add array_hook parameter to JSON decoders (#146441) 2026-03-27 11:10:48 +00:00
test_default.py
test_dump.py gh-145244: Fix use-after-free on borrowed dict key in json encoder (GH-145245) 2026-04-11 22:26:36 +00:00
test_encode_basestring_ascii.py gh-148241: Fix json serialization for str subclasses (#148249) 2026-04-09 13:50:44 +02:00
test_enum.py gh-148241: Fix json serialization for str subclasses (#148249) 2026-04-09 13:50:44 +02:00
test_fail.py
test_float.py
test_indent.py
test_pass1.py
test_pass2.py
test_pass3.py
test_recursion.py gh-143460: Skip infinite recusion tests for infinite stack size (#143606) 2026-01-09 16:11:37 +00:00
test_scanstring.py gh-137821: Improve Argument Clinic definitions in the `_json` module (#140780) 2025-10-30 10:32:08 +00:00
test_separators.py
test_speedups.py gh-143196: Fix crash in non-standard use of internal JSON encoder object (GH-143618) 2026-01-12 18:23:05 +00:00
test_tool.py gh-140172: Skip JSON tools test during PGO training (GH-140809) 2025-12-11 00:34:49 +00:00
test_unicode.py gh-140793: Improve documentatation and tests for the ensure_ascii option in the json module (GH-140906) 2025-11-08 12:07:27 +02:00