From 1c58e954e66e5392ffd03173ea3eff38bf3a17f6 Mon Sep 17 00:00:00 2001 From: Yan Yanchii Date: Mon, 23 Dec 2024 17:13:36 +0100 Subject: [PATCH] Add `PyIter_Next error check in `namespaceobject.c` --- Objects/namespaceobject.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Objects/namespaceobject.c b/Objects/namespaceobject.c index 5b7547103a2b3f..c450a51bbc3b99 100644 --- a/Objects/namespaceobject.c +++ b/Objects/namespaceobject.c @@ -141,6 +141,11 @@ namespace_repr(PyObject *ns) goto error; } + /* Check if loop ended because of exception in PyIter_Next */ + if (PyErr_Occurred()) { + goto error; + } + separator = PyUnicode_FromString(", "); if (separator == NULL) goto error;