Skip to content

Commit

Permalink
pythongh-105375: Harden error handling in _testcapi/heaptype.c (pyt…
Browse files Browse the repository at this point in the history
…hon#105608)

Bail on first error in heapctypesubclasswithfinalizer_finalize()
  • Loading branch information
erlend-aasland committed Jun 9, 2023
1 parent 33c92c4 commit d636d7d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Modules/_testcapi/heaptype.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down

0 comments on commit d636d7d

Please sign in to comment.