[3.12] gh-105375: Harden error handling in _testcapi/heaptype.c (GH-105608) (#105615)

Bail on first error in heapctypesubclasswithfinalizer_finalize()
(cherry picked from commit d636d7dfe7)

Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
This commit is contained in:
Miss Islington (bot) 2023-06-09 16:21:42 -07:00 committed by GitHub
parent 5dae2b1a5d
commit 4fbbf699c0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View 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;
}