]> granicus.if.org Git - python/commitdiff
Issue #18559: Fix NULL pointer dereference error in _pickle module
authorChristian Heimes <christian@cheimes.de>
Fri, 26 Jul 2013 20:45:00 +0000 (22:45 +0200)
committerChristian Heimes <christian@cheimes.de>
Fri, 26 Jul 2013 20:45:00 +0000 (22:45 +0200)
Misc/NEWS
Modules/_pickle.c

index 8c23a9e56bb239ec8ae3e96820ae1acf7855aac1..24b0c53f6cd0bcd058c6c83374e4c7dd03497ea3 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -52,6 +52,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #18559: Fix NULL pointer dereference error in _pickle module
+
 - Issue #18556: Check the return value of a PyUnicode_AsWideChar() call in
   ctypes' U_set().
 
index 0252c623398a7724f0aca00575c0a79cf94af8d8..ce573cf9f91178f1e759ebd8b77113f5f163fbd4 100644 (file)
@@ -4816,9 +4816,10 @@ load_binget(UnpicklerObject *self)
     value = _Unpickler_MemoGet(self, idx);
     if (value == NULL) {
         PyObject *key = PyLong_FromSsize_t(idx);
-        if (!PyErr_Occurred())
+        if (key != NULL) {
             PyErr_SetObject(PyExc_KeyError, key);
-        Py_DECREF(key);
+            Py_DECREF(key);
+        }
         return -1;
     }
 
@@ -4841,9 +4842,10 @@ load_long_binget(UnpicklerObject *self)
     value = _Unpickler_MemoGet(self, idx);
     if (value == NULL) {
         PyObject *key = PyLong_FromSsize_t(idx);
-        if (!PyErr_Occurred())
+        if (key != NULL) {
             PyErr_SetObject(PyExc_KeyError, key);
-        Py_DECREF(key);
+            Py_DECREF(key);
+        }
         return -1;
     }