summaryrefslogtreecommitdiffstats
path: root/Modules/_pickle.c
diff options
context:
space:
mode:
authorMat M <mathew1800@gmail.com>2017-11-13 07:50:16 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2017-11-13 07:50:16 (GMT)
commitf76231f89a7231fd486b37f728fbb4aab389e4d7 (patch)
treeb620ee10abb077ca86699553cd227537a35fdd21 /Modules/_pickle.c
parent8acaa31eec84010c2211b838cffa9f69a91a5240 (diff)
downloadcpython-f76231f89a7231fd486b37f728fbb4aab389e4d7.zip
cpython-f76231f89a7231fd486b37f728fbb4aab389e4d7.tar.gz
cpython-f76231f89a7231fd486b37f728fbb4aab389e4d7.tar.bz2
bpo-32013: _pickle: Add missing Py_DECREF in error case in fast_save_enter() (#4384)
Diffstat (limited to 'Modules/_pickle.c')
-rw-r--r--Modules/_pickle.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index b71fb93..4b7f1ed 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -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) {