diff options
author | Christian Heimes <christian@cheimes.de> | 2013-07-26 22:49:26 +0200 |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2018-08-23 21:32:36 -0700 |
commit | 32f7fdd757283a2456ad1c1bf8fae60a224c13cc (patch) | |
tree | 2cd5d1cf5615507a4091f36faba48bcfa74724c0 /Python/bltinmodule.c | |
parent | 5c437d6fd81f5400504eadd2c578b39a0f052bd0 (diff) | |
download | cpython-git-backport-704e2d3-2.7.tar.gz |
[2.7] Issue GH-18560: Fix potential NULL pointer dereference in sum().backport-704e2d3-2.7
(cherry picked from commit 704e2d374f88bca83339b95d559b0abce12dc6bd)
Co-authored-by: Christian Heimes <christian@cheimes.de>
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index f19115d2cb..f38fcaca71 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2363,6 +2363,11 @@ builtin_sum(PyObject *self, PyObject *args) } /* Either overflowed or is not an int. Restore real objects and process normally */ result = PyInt_FromLong(i_result); + if (result == NULL) { + Py_DECREF(item); + Py_DECREF(iter); + return NULL; + } temp = PyNumber_Add(result, item); Py_DECREF(result); Py_DECREF(item); |