Skip to content

Commit 2b824b2

Browse files
Alexey Izbyshevbenjaminp
authored andcommitted
closes bpo-34474: Python/bltinmodule.c: Add missing NULL check in builtin_sum_impl() (GH-8872)
Reported by Svace static analyzer.
1 parent f6247aa commit 2b824b2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Python/bltinmodule.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,6 +2401,11 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start)
24012401
}
24022402
}
24032403
result = PyFloat_FromDouble(f_result);
2404+
if (result == NULL) {
2405+
Py_DECREF(item);
2406+
Py_DECREF(iter);
2407+
return NULL;
2408+
}
24042409
temp = PyNumber_Add(result, item);
24052410
Py_DECREF(result);
24062411
Py_DECREF(item);

0 commit comments

Comments
 (0)