summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2018-08-24 01:10:58 -0400
committerGitHub <noreply@github.com>2018-08-24 01:10:58 -0400
commit7d470f3f24d0c091cf1da4f13695c6bb3200a713 (patch)
tree02b22c072fafd66e3e214d66adac2419dc4cc410 /Python
parentfbe359a5e0b22e96065d24d033bebf27cdb374be (diff)
downloadcpython-git-7d470f3f24d0c091cf1da4f13695c6bb3200a713.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 5ee08e67e7..d7b0bbd331 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -2343,6 +2343,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);