]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-34456: pickle: Add missing NULL check to save_global(). (GH-8851)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 22 Aug 2018 05:54:39 +0000 (01:54 -0400)
committerGitHub <noreply@github.com>
Wed, 22 Aug 2018 05:54:39 +0000 (01:54 -0400)
Reported by Svace static analyzer.
(cherry picked from commit f8c06b028036e50596e75d4c9f6b27ba05133efe)

Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
Modules/_pickle.c

index 10c8371d67408c86fc8201dd174517b3bcbe7b3b..f5202f50c547f683490e1df46abb5e7de890f8ac 100644 (file)
@@ -3349,6 +3349,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)