mirror of
https://github.com/python/cpython.git
synced 2025-09-29 11:45:57 +00:00
bpo-32013: _pickle: Add missing Py_DECREF in error case in fast_save_enter() (GH-4384) (#4385)
(cherry picked from commit f76231f89a
)
This commit is contained in:
parent
ad004f9b5a
commit
6ed9d4ecde
1 changed files with 5 additions and 1 deletions
|
@ -1731,8 +1731,10 @@ fast_save_enter(PicklerObject *self, PyObject *obj)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
key = PyLong_FromVoidPtr(obj);
|
key = PyLong_FromVoidPtr(obj);
|
||||||
if (key == NULL)
|
if (key == NULL) {
|
||||||
|
self->fast_nesting = -1;
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
if (PyDict_GetItemWithError(self->fast_memo, key)) {
|
if (PyDict_GetItemWithError(self->fast_memo, key)) {
|
||||||
Py_DECREF(key);
|
Py_DECREF(key);
|
||||||
PyErr_Format(PyExc_ValueError,
|
PyErr_Format(PyExc_ValueError,
|
||||||
|
@ -1743,6 +1745,8 @@ fast_save_enter(PicklerObject *self, PyObject *obj)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (PyErr_Occurred()) {
|
if (PyErr_Occurred()) {
|
||||||
|
Py_DECREF(key);
|
||||||
|
self->fast_nesting = -1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
if (PyDict_SetItem(self->fast_memo, key, Py_None) < 0) {
|
if (PyDict_SetItem(self->fast_memo, key, Py_None) < 0) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue