mirror of https://github.com/python/cpython
bpo-32013: _pickle: Add missing Py_DECREF in error case in fast_save_enter() (#4384)
This commit is contained in:
parent
8acaa31eec
commit
f76231f89a
|
@ -1777,8 +1777,10 @@ fast_save_enter(PicklerObject *self, PyObject *obj)
|
|||
}
|
||||
}
|
||||
key = PyLong_FromVoidPtr(obj);
|
||||
if (key == NULL)
|
||||
if (key == NULL) {
|
||||
self->fast_nesting = -1;
|
||||
return 0;
|
||||
}
|
||||
if (PyDict_GetItemWithError(self->fast_memo, key)) {
|
||||
Py_DECREF(key);
|
||||
PyErr_Format(PyExc_ValueError,
|
||||
|
@ -1789,6 +1791,8 @@ fast_save_enter(PicklerObject *self, PyObject *obj)
|
|||
return 0;
|
||||
}
|
||||
if (PyErr_Occurred()) {
|
||||
Py_DECREF(key);
|
||||
self->fast_nesting = -1;
|
||||
return 0;
|
||||
}
|
||||
if (PyDict_SetItem(self->fast_memo, key, Py_None) < 0) {
|
||||
|
|
Loading…
Reference in New Issue