From 89fa05fdce20cc0a19689eb365f1828b086d0b17 Mon Sep 17 00:00:00 2001 From: Petr Viktorin Date: Mon, 29 Jul 2024 18:10:25 +0200 Subject: [PATCH] gh-122234: Add DECREFs to error paths (#122406) Co-Authored-By: Kirill Podoprigora --- Python/bltinmodule.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index ae025e767ec..99ed06972be 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -2694,6 +2694,8 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start) continue; } else { + Py_DECREF(item); + Py_DECREF(iter); return NULL; } } @@ -2745,6 +2747,8 @@ builtin_sum_impl(PyObject *module, PyObject *iterable, PyObject *start) continue; } else { + Py_DECREF(item); + Py_DECREF(iter); return NULL; } }