[Python-checkins] bpo-32013: _pickle: Add missing Py_DECREF in error case in fast_save_enter() (GH-4384) (#4385)

Serhiy Storchaka webhook-mailer at python.org
Mon Nov 13 03:19:55 EST 2017


https://github.com/python/cpython/commit/6ed9d4ecde8c3f0eeadf188f15a5bbd32b9d1145
commit: 6ed9d4ecde8c3f0eeadf188f15a5bbd32b9d1145
branch: 3.6
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: Serhiy Storchaka <storchaka at gmail.com>
date: 2017-11-13T10:19:52+02:00
summary:

bpo-32013: _pickle: Add missing Py_DECREF in error case in fast_save_enter() (GH-4384) (#4385)

(cherry picked from commit f76231f89a7231fd486b37f728fbb4aab389e4d7)

files:
M Modules/_pickle.c

diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index bc1af548072..198474d88bf 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1731,8 +1731,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,
@@ -1743,6 +1745,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) {



More information about the Python-checkins mailing list