]> granicus.if.org Git - python/commitdiff
bpo-32013: _pickle: Add missing Py_DECREF in error case in fast_save_enter() (GH...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Mon, 13 Nov 2017 08:19:52 +0000 (00:19 -0800)
committerSerhiy Storchaka <storchaka@gmail.com>
Mon, 13 Nov 2017 08:19:52 +0000 (10:19 +0200)
(cherry picked from commit f76231f89a7231fd486b37f728fbb4aab389e4d7)

Modules/_pickle.c

index bc1af54807237761f2f1fbf51a6109be19184183..198474d88bf58d42aa3a0d4c31dd403db006d479 100644 (file)
@@ -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) {