From: Erlend E. Aasland Date: Fri, 9 Jun 2023 21:53:33 +0000 (+0200) Subject: gh-105375: Harden error handling in `_testcapi/heaptype.c` (#105608) X-Git-Tag: v3.13.0a1~1805 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d636d7dfe714e7168b342c7ea5f9f9d3b3569ed0;p=thirdparty%2FPython%2Fcpython.git gh-105375: Harden error handling in `_testcapi/heaptype.c` (#105608) Bail on first error in heapctypesubclasswithfinalizer_finalize() --- diff --git a/Modules/_testcapi/heaptype.c b/Modules/_testcapi/heaptype.c index 3488e35922c5..565ab570a42b 100644 --- a/Modules/_testcapi/heaptype.c +++ b/Modules/_testcapi/heaptype.c @@ -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; }