diff options
author | Benjamin Peterson <benjamin@python.org> | 2018-08-24 05:28:39 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-24 05:28:39 (GMT) |
commit | 67dafd5c202cd529e209bf3f35e022ce766709eb (patch) | |
tree | f88ab52669231201975fca93a38ebf5afb3d4e46 /Python | |
parent | 45ee452751d095d665717bafb61cfd7c65b729b4 (diff) | |
download | cpython-67dafd5c202cd529e209bf3f35e022ce766709eb.zip cpython-67dafd5c202cd529e209bf3f35e022ce766709eb.tar.gz cpython-67dafd5c202cd529e209bf3f35e022ce766709eb.tar.bz2 |
[2.7] Issue GH-18560: Fix potential NULL pointer dereference in sum(). (GH-8892)
(cherry picked from commit 704e2d374f88bca83339b95d559b0abce12dc6bd)
Co-authored-by: Christian Heimes <christian@cheimes.de>
Diffstat (limited to 'Python')
-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 21f6e66..4b819da 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); |