Skip to content

Commit

Permalink
bpo-32013: _pickle: Add missing Py_DECREF in error case in fast_save_…
Browse files Browse the repository at this point in the history
…enter() (python#4384)
  • Loading branch information
lioncash authored and serhiy-storchaka committed Nov 13, 2017
1 parent 8acaa31 commit f76231f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Modules/_pickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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) {
Expand Down

0 comments on commit f76231f

Please sign in to comment.