From 4fbbf699c0d72f6db62484c88a05c826c3703eb5 Mon Sep 17 00:00:00 2001 From: "Miss Islington (bot)" <31488909+miss-islington@users.noreply.github.com> Date: Fri, 9 Jun 2023 16:21:42 -0700 Subject: [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 d636d7dfe714e7168b342c7ea5f9f9d3b3569ed0) Co-authored-by: Erlend E. Aasland --- Modules/_testcapi/heaptype.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Modules/_testcapi/heaptype.c b/Modules/_testcapi/heaptype.c index 3488e35..565ab57 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; } -- cgit v0.12