Skip to content

Commit f76231f

Browse files
lioncashserhiy-storchaka
authored andcommitted
bpo-32013: _pickle: Add missing Py_DECREF in error case in fast_save_enter() (python#4384)
1 parent 8acaa31 commit f76231f

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Modules/_pickle.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1777,8 +1777,10 @@ fast_save_enter(PicklerObject *self, PyObject *obj)
17771777
}
17781778
}
17791779
key = PyLong_FromVoidPtr(obj);
1780-
if (key == NULL)
1780+
if (key == NULL) {
1781+
self->fast_nesting = -1;
17811782
return 0;
1783+
}
17821784
if (PyDict_GetItemWithError(self->fast_memo, key)) {
17831785
Py_DECREF(key);
17841786
PyErr_Format(PyExc_ValueError,
@@ -1789,6 +1791,8 @@ fast_save_enter(PicklerObject *self, PyObject *obj)
17891791
return 0;
17901792
}
17911793
if (PyErr_Occurred()) {
1794+
Py_DECREF(key);
1795+
self->fast_nesting = -1;
17921796
return 0;
17931797
}
17941798
if (PyDict_SetItem(self->fast_memo, key, Py_None) < 0) {

0 commit comments

Comments
 (0)