From 97b06d543fed66d8393c46ea7d01af50ce66e4ca Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Sun, 14 Jul 2024 13:48:33 +0200 Subject: [PATCH] [3.13] gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result (GH-121661) (#121761) gh-121660: Fix `ga_getitem` by explicitly checking for `NULL` result (GH-121661) (cherry picked from commit bb802db8cfa35a88582be32fae05fe1cf8f237b1) Co-authored-by: sobolevn --- Objects/genericaliasobject.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c index 2779baf0bd1..3c64e75fca8 100644 --- a/Objects/genericaliasobject.c +++ b/Objects/genericaliasobject.c @@ -561,6 +561,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);