]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-105375: Harden error handling in `_testcapi/heaptype.c` (#105608)
authorErlend E. Aasland <erlend.aasland@protonmail.com>
Fri, 9 Jun 2023 21:53:33 +0000 (23:53 +0200)
committerGitHub <noreply@github.com>
Fri, 9 Jun 2023 21:53:33 +0000 (21:53 +0000)
Bail on first error in heapctypesubclasswithfinalizer_finalize()

Modules/_testcapi/heaptype.c

index 3488e35922c5ac982a3199b8ff772f7f90223cac..565ab570a42bde7fa7997d27177b5da75cf0ffc2 100644 (file)
@@ -661,8 +661,11 @@ heapctypesubclasswithfinalizer_finalize(PyObject *self)
         goto cleanup_finalize;
     }
     oldtype = PyObject_GetAttrString(m, "HeapCTypeSubclassWithFinalizer");
+    if (oldtype == NULL) {
+        goto cleanup_finalize;
+    }
     newtype = PyObject_GetAttrString(m, "HeapCTypeSubclass");
-    if (oldtype == NULL || newtype == NULL) {
+    if (newtype == NULL) {
         goto cleanup_finalize;
     }