From bb802db8cfa35a88582be32fae05fe1cf8f237b1 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sun, 14 Jul 2024 14:20:40 +0300 Subject: [PATCH] gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result (#121661) --- Objects/genericaliasobject.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index f5fefd65653..96c96491501 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -563,6 +563,10 @@ ga_getitem(PyObject *self, PyObject *item) } PyObject *res = Py_GenericAlias(alias->origin, newargs); + if (res == NULL) { + Py_DECREF(newargs); + return NULL; + } ((gaobject *)res)->starred = alias->starred; Py_DECREF(newargs);