Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 31a3ec3

Browse files
committed
Issue #22338: Fix a crash in the json module on memory allocation failure.
1 parent 6d46dff commit 31a3ec3

2 files changed

Lines changed: 4 additions & 1 deletion

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ Core and Builtins
3232
Library
3333
-------
3434

35+
- Issue #22338: Fix a crash in the json module on memory allocation failure.
36+
3537
- Issue #22226: First letter no longer is stripped from the "status" key in
3638
the result of Treeview.heading().
3739

Modules/_json.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,7 @@ _build_rval_index_tuple(PyObject *rval, Py_ssize_t idx) {
287287
} \
288288
} \
289289
if (PyList_Append(chunks, chunk)) { \
290-
Py_DECREF(chunk); \
290+
Py_CLEAR(chunk); \
291291
goto bail; \
292292
} \
293293
Py_CLEAR(chunk); \
@@ -1555,6 +1555,7 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc,
15551555
if (item == NULL)
15561556
goto bail;
15571557
PyList_SET_ITEM(items, i, item);
1558+
item = NULL;
15581559
Py_DECREF(key);
15591560
}
15601561
}

0 commit comments

Comments
 (0)