Skip to content

Commit 704e2d3

Browse files
committed
Issue #18560: Fix potential NULL pointer dereference in sum()
1 parent 9ee5c37 commit 704e2d3

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's New in Python 3.3.3 release candidate 1?
1212
Core and Builtins
1313
-----------------
1414

15+
- Issue #18560: Fix potential NULL pointer dereference in sum().
16+
1517
- Issue #15905: Fix theoretical buffer overflow in handling of sys.argv[0],
1618
prefix and exec_prefix if the operation system does not obey MAXPATHLEN.
1719

Python/bltinmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2009,6 +2009,11 @@ builtin_sum(PyObject *self, PyObject *args)
20092009
}
20102010
/* Either overflowed or is not an int. Restore real objects and process normally */
20112011
result = PyLong_FromLong(i_result);
2012+
if (result == NULL) {
2013+
Py_DECREF(item);
2014+
Py_DECREF(iter);
2015+
return NULL;
2016+
}
20122017
temp = PyNumber_Add(result, item);
20132018
Py_DECREF(result);
20142019
Py_DECREF(item);

0 commit comments

Comments
 (0)