summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2014-09-10 21:32:36 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2014-09-10 21:32:36 (GMT)
commit8ebf9106129e59e54a852cd7643510d85a30840e (patch)
tree66931c6c0bf2317ccdbe0ce418f4ac1e8dfc6636
parenteeca5f82fd2645a988cbbed016a7b7100ec91deb (diff)
parent31a3ec313d442fd9d64a3882669da634d7b70d56 (diff)
downloadcpython-8ebf9106129e59e54a852cd7643510d85a30840e.zip
cpython-8ebf9106129e59e54a852cd7643510d85a30840e.tar.gz
cpython-8ebf9106129e59e54a852cd7643510d85a30840e.tar.bz2
(Merge 3.4) Issue #22338: Fix a crash in the json module on memory allocation
failure.
-rw-r--r--Misc/NEWS2
-rw-r--r--Modules/_json.c3
2 files changed, 4 insertions, 1 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 4dd8de3..49909a1 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -132,6 +132,8 @@ Core and Builtins
Library
-------
+- Issue #22338: Fix a crash in the json module on memory allocation failure.
+
- Issue #12410: imaplib.IMAP4 now supports the context management protocol.
Original patch by Tarek Ziadé.
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 @@ _build_rval_index_tuple(PyObject *rval, Py_ssize_t idx) {
} \
} \
if (PyList_Append(chunks, chunk)) { \
- Py_DECREF(chunk); \
+ Py_CLEAR(chunk); \
goto bail; \
} \
Py_CLEAR(chunk); \
@@ -1555,6 +1555,7 @@ encoder_listencode_dict(PyEncoderObject *s, _PyAccu *acc,
if (item == NULL)
goto bail;
PyList_SET_ITEM(items, i, item);
+ item = NULL;
Py_DECREF(key);
}
}