From b511efcddb42476ab2d4d56c403d8a09f3af3786 Mon Sep 17 00:00:00 2001 From: sobolevn Date: Sat, 13 Jul 2024 11:20:28 +0300 Subject: [PATCH] gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result --- Objects/genericaliasobject.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index f5fefd656539c8..96c96491501a2c 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);