Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 4ebf6d7

Browse files
committed
Issue #18560: Fix potential NULL pointer dereference in sum()
2 parents f446d21 + 704e2d3 commit 4ebf6d7

2 files changed

Lines changed: 7 additions & 0 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ What's New in Python 3.4.0 Alpha 1?
1010
Core and Builtins
1111
-----------------
1212

13+
- Issue #18560: Fix potential NULL pointer dereference in sum().
14+
1315
- Issue #18520: Add a new PyStructSequence_InitType2() function, same than
1416
PyStructSequence_InitType() except that it has a return value (0 on success,
1517
-1 on error).

Python/bltinmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,6 +2030,11 @@ builtin_sum(PyObject *self, PyObject *args)
20302030
}
20312031
/* Either overflowed or is not an int. Restore real objects and process normally */
20322032
result = PyLong_FromLong(i_result);
2033+
if (result == NULL) {
2034+
Py_DECREF(item);
2035+
Py_DECREF(iter);
2036+
return NULL;
2037+
}
20332038
temp = PyNumber_Add(result, item);
20342039
Py_DECREF(result);
20352040
Py_DECREF(item);

0 commit comments

Comments
 (0)