closes bpo-34474: Python/bltinmodule.c: Add missing NULL check in builtin_sum_impl() (GH-8872)

Reported by Svace static analyzer.
This commit is contained in:
Alexey Izbyshev 2018-08-24 07:27:52 +03:00 committed by Benjamin Peterson
parent f6247aac08
commit 2b824b2538
1 changed files with 5 additions and 0 deletions

View File

@ -2401,6 +2401,11 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
} }
} }
result = PyFloat_FromDouble(f_result); result = PyFloat_FromDouble(f_result);
if (result == NULL) {
Py_DECREF(item);
Py_DECREF(iter);
return NULL;
}
temp = PyNumber_Add(result, item); temp = PyNumber_Add(result, item);
Py_DECREF(result); Py_DECREF(result);
Py_DECREF(item); Py_DECREF(item);