Commit 67dafd5c authored by Benjamin Peterson's avatar Benjamin Peterson Committed by GitHub

[2.7] Issue GH-18560: Fix potential NULL pointer dereference in sum(). (GH-8892)

(cherry picked from commit 704e2d37)
Co-authored-by: default avatarChristian Heimes <christian@cheimes.de>
parent 45ee4527
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment