bpo-34456: pickle: Add missing NULL check to save_global(). (GH-8851)

Reported by Svace static analyzer.
This commit is contained in:
Alexey Izbyshev 2018-08-22 07:51:25 +03:00 committed by Serhiy Storchaka
parent ef8861c112
commit f8c06b0280
1 changed files with 2 additions and 0 deletions

View 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)