]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34456: pickle: Add missing NULL check to save_global(). (GH-8851)
authorAlexey Izbyshev <izbyshev@ispras.ru>
Wed, 22 Aug 2018 04:51:25 +0000 (07:51 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Wed, 22 Aug 2018 04:51:25 +0000 (07:51 +0300)
Reported by Svace static analyzer.

Modules/_pickle.c

index ea778c763520fcee4a65401a3ab752c9cb328693..517c99e1746b8867953189bb710731f25a5e9d91 100644 (file)
@@ -3454,6 +3454,8 @@ save_global(PicklerObject *self, PyObject *obj, PyObject *name)
             PickleState *st = _Pickle_GetGlobalState();
             PyObject *reduce_value = Py_BuildValue("(O(OO))",
                                         st->getattr, parent, lastname);
+            if (reduce_value == NULL)
+                goto error;
             status = save_reduce(self, reduce_value, NULL);
             Py_DECREF(reduce_value);
             if (status < 0)