Issue #22338: Fix a crash in the json module on memory allocation failure.
diff --git a/Misc/NEWS b/Misc/NEWS
index cd6dadc..91125e7 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -32,6 +32,8 @@
Library
-------
+- Issue #22338: Fix a crash in the json module on memory allocation failure.
+
- Issue #22226: First letter no longer is stripped from the "status" key in
the result of Treeview.heading().
diff --git a/Modules/_json.c b/Modules/_json.c
index 20f4614..1580ee6 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -287,7 +287,7 @@
} \
} \
if (PyList_Append(chunks, chunk)) { \
- Py_DECREF(chunk); \
+ Py_CLEAR(chunk); \
goto bail; \
} \
Py_CLEAR(chunk); \
@@ -1555,6 +1555,7 @@
if (item == NULL)
goto bail;
PyList_SET_ITEM(items, i, item);
+ item = NULL;
Py_DECREF(key);
}
}