Skip to content

Commit 4fbbf69

Browse files
[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 d636d7d) Co-authored-by: Erlend E. Aasland <[email protected]>
1 parent 5dae2b1 commit 4fbbf69

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Modules/_testcapi/heaptype.c

+4-1
Original file line numberDiff line numberDiff line change
@@ -661,8 +661,11 @@ heapctypesubclasswithfinalizer_finalize(PyObject *self)
661661
goto cleanup_finalize;
662662
}
663663
oldtype = PyObject_GetAttrString(m, "HeapCTypeSubclassWithFinalizer");
664+
if (oldtype == NULL) {
665+
goto cleanup_finalize;
666+
}
664667
newtype = PyObject_GetAttrString(m, "HeapCTypeSubclass");
665-
if (oldtype == NULL || newtype == NULL) {
668+
if (newtype == NULL) {
666669
goto cleanup_finalize;
667670
}
668671

0 commit comments

Comments
 (0)