gh-105375: Harden error handling in `_testcapi/heaptype.c` (#105608)

Bail on first error in heapctypesubclasswithfinalizer_finalize()
This commit is contained in:
Erlend E. Aasland 2023-06-09 23:53:33 +02:00 committed by GitHub
parent 33c92c4f15
commit d636d7dfe7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 1 deletions

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