Skip to content

Commit d636d7d

Browse files
gh-105375: Harden error handling in _testcapi/heaptype.c (#105608)
Bail on first error in heapctypesubclasswithfinalizer_finalize()
1 parent 33c92c4 commit d636d7d

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

Modules/_testcapi/heaptype.c

Lines changed: 4 additions & 1 deletion
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)