Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9ee5c37

Browse files
committed
Issue #18559: Fix NULL pointer dereference error in _pickle module
1 parent 66eda26 commit 9ee5c37

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ Core and Builtins
5252
Library
5353
-------
5454

55+
- Issue #18559: Fix NULL pointer dereference error in _pickle module
56+
5557
- Issue #18556: Check the return value of a PyUnicode_AsWideChar() call in
5658
ctypes' U_set().
5759

Modules/_pickle.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4816,9 +4816,10 @@ load_binget(UnpicklerObject *self)
48164816
value = _Unpickler_MemoGet(self, idx);
48174817
if (value == NULL) {
48184818
PyObject *key = PyLong_FromSsize_t(idx);
4819-
if (!PyErr_Occurred())
4819+
if (key != NULL) {
48204820
PyErr_SetObject(PyExc_KeyError, key);
4821-
Py_DECREF(key);
4821+
Py_DECREF(key);
4822+
}
48224823
return -1;
48234824
}
48244825

@@ -4841,9 +4842,10 @@ load_long_binget(UnpicklerObject *self)
48414842
value = _Unpickler_MemoGet(self, idx);
48424843
if (value == NULL) {
48434844
PyObject *key = PyLong_FromSsize_t(idx);
4844-
if (!PyErr_Occurred())
4845+
if (key != NULL) {
48454846
PyErr_SetObject(PyExc_KeyError, key);
4846-
Py_DECREF(key);
4847+
Py_DECREF(key);
4848+
}
48474849
return -1;
48484850
}
48494851

0 commit comments

Comments
 (0)