]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-44562: Remove invalid PyObject_GC_Del from error path of types.GenericAlias ...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 4 Jul 2021 17:55:35 +0000 (10:55 -0700)
committerGitHub <noreply@github.com>
Sun, 4 Jul 2021 17:55:35 +0000 (10:55 -0700)
(cherry picked from commit d33943a6c368c2184e238019c63ac7a267da5594)

Co-authored-by: Ken Jin <28750310+Fidget-Spinner@users.noreply.github.com>
Misc/NEWS.d/next/Core and Builtins/2021-07-04-23-38-51.bpo-44562.QdeRQo.rst [new file with mode: 0644]
Objects/genericaliasobject.c

diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-07-04-23-38-51.bpo-44562.QdeRQo.rst b/Misc/NEWS.d/next/Core and Builtins/2021-07-04-23-38-51.bpo-44562.QdeRQo.rst
new file mode 100644 (file)
index 0000000..2fc65bc
--- /dev/null
@@ -0,0 +1,2 @@
+Remove uses of :c:func:`PyObject_GC_Del` in error path when initializing
+:class:`types.GenericAlias`.
index 756a7ce474aee92afde996747a10a3ac88d2b290..48a8be1c458752a4a4637f2ec0bd4c87a13f781f 100644 (file)
@@ -603,7 +603,7 @@ ga_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
         return NULL;
     }
     if (!setup_ga(self, origin, arguments)) {
-        type->tp_free((PyObject *)self);
+        Py_DECREF(self);
         return NULL;
     }
     return (PyObject *)self;
@@ -650,10 +650,10 @@ Py_GenericAlias(PyObject *origin, PyObject *args)
     if (alias == NULL) {
         return NULL;
     }
+    _PyObject_GC_TRACK(alias);
     if (!setup_ga(alias, origin, args)) {
-        PyObject_GC_Del((PyObject *)alias);
+        Py_DECREF(alias);
         return NULL;
     }
-    _PyObject_GC_TRACK(alias);
     return (PyObject *)alias;
 }