From 4c9ea6ec10ae2e4678611da62de80c16f7a0ce1d Mon Sep 17 00:00:00 2001 From: Yan Yanchii Date: Tue, 9 Jan 2024 11:43:58 +0100 Subject: [PATCH] gh-113842: Add missing error check for PyIter_Next() in Python/symtable.c (GH-113843) (cherry picked from commit fda901a1ff94ea6cc338b74928acdbc5ee165ed7) Co-authored-by: Yan Yanchii --- Python/symtable.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Python/symtable.c b/Python/symtable.c index 70b6eacd4ac071..a5c6b465b71ddd 100644 --- a/Python/symtable.c +++ b/Python/symtable.c @@ -872,6 +872,12 @@ update_symbols(PyObject *symbols, PyObject *scopes, } Py_DECREF(name); } + + /* Check if loop ended because of exception in PyIter_Next */ + if (PyErr_Occurred()) { + goto error; + } + Py_DECREF(itr); Py_DECREF(v_free); return 1;