]> granicus.if.org Git - python/commitdiff
Issue #22338: Fix a crash in the json module on memory allocation failure.
authorVictor Stinner <victor.stinner@gmail.com>
Wed, 10 Sep 2014 21:31:42 +0000 (23:31 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Wed, 10 Sep 2014 21:31:42 +0000 (23:31 +0200)
Misc/NEWS
Modules/_json.c

index cd6dadc87c74aef1c80ef71b9491f204cd27c450..91125e708db5896e07bebf980a4c779b62e953b4 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -32,6 +32,8 @@ Core and Builtins
 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().
 
index 20f4614c7d942821946a2b6d7c76ccd480278d15..1580ee6b658d3f91453562e69e9704486aec04a0 100644 (file)
@@ -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);
         }
     }