From: Alexey Izbyshev Date: Fri, 24 Aug 2018 04:27:52 +0000 (+0300) Subject: closes bpo-34474: Python/bltinmodule.c: Add missing NULL check in builtin_sum_impl... X-Git-Tag: v3.8.0a1~1172 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2b824b2538c4a5f9f520c5de8a1eae5a0c181a94;p=thirdparty%2FPython%2Fcpython.git closes bpo-34474: Python/bltinmodule.c: Add missing NULL check in builtin_sum_impl() (GH-8872) Reported by Svace static analyzer. --- diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 4b12048f9d56..8aa1ba01d659 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2401,6 +2401,11 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start) } } result = PyFloat_FromDouble(f_result); + if (result == NULL) { + Py_DECREF(item); + Py_DECREF(iter); + return NULL; + } temp = PyNumber_Add(result, item); Py_DECREF(result); Py_DECREF(item);