[Python-checkins] cpython (merge 3.4 -> default): (Merge 3.4) Issue #22338: Fix a crash in the json module on memory allocation

victor.stinner python-checkins at python.org
Wed Sep 10 23:34:55 CEST 2014


http://hg.python.org/cpython/rev/135fc23e475c
changeset:   92391:135fc23e475c
parent:      92389:e3a3c8809d09
parent:      92390:3ac9f9576ce6
user:        Victor Stinner <victor.stinner at gmail.com>
date:        Wed Sep 10 23:32:36 2014 +0200
summary:
  (Merge 3.4) Issue #22338: Fix a crash in the json module on memory allocation
failure.

files:
  Misc/NEWS       |  2 ++
  Modules/_json.c |  3 ++-
  2 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -132,6 +132,8 @@
 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
--- 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);
         }
     }

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list