summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-08-24 01:13:19 -0400
committerGitHub <noreply@github.com>2018-08-24 01:13:19 -0400
commit45ee452751d095d665717bafb61cfd7c65b729b4 (patch)
tree0f6b6b2c3c71c72aee72f3811ff0e89597ee2b4d /Python
parentea21206626d0907e0ecfd3efbb186f14f1a8a5d4 (diff)
downloadcpython-git-45ee452751d095d665717bafb61cfd7c65b729b4.tar.gz
closes bpo-34474: Python/bltinmodule.c: Add missing NULL check in builtin_sum_impl() (GH-8872)
Reported by Svace static analyzer. (cherry picked from commit 2b824b2538c4a5f9f520c5de8a1eae5a0c181a94) Co-authored-by: Alexey Izbyshev <izbyshev@ispras.ru>
Diffstat (limited to 'Python')
-rw-r--r--Python/bltinmodule.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index f19115d2cb..21f6e66d82 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2401,6 +2401,11 @@ builtin_sum(PyObject *self, PyObject *args)
continue;
}
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);