From: Christian Heimes Date: Fri, 26 Jul 2013 20:45:00 +0000 (+0200) Subject: Issue #18559: Fix NULL pointer dereference error in _pickle module X-Git-Tag: v3.4.0a1~72^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9ee5c37c8f8c4f35814453aecf5fdfd01dfa2781;p=python Issue #18559: Fix NULL pointer dereference error in _pickle module --- diff --git a/Misc/NEWS b/Misc/NEWS index 8c23a9e56b..24b0c53f6c 100644 --- 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(). diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 0252c62339..ce573cf9f9 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -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; }