From fa5af0da5975a06f4208ef0d2c724f2388358f89 Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Thu, 4 Dec 2025 08:17:13 +0000 Subject: [PATCH] Fix reference leaks introduced in GH-140800 --- Python/ceval.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Python/ceval.c b/Python/ceval.c index 1709dda0cbe145..46bf644106ac39 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -1228,6 +1228,8 @@ _Py_BuildString_StackRefSteal( goto cleanup; } res = _PyUnicode_JoinArray(&_Py_STR(empty), args_o, total_args); + STACKREFS_TO_PYOBJECTS_CLEANUP(args_o); + assert((res != NULL) ^ (PyErr_Occurred() != NULL)); cleanup: // arguments is a pointer into the GC visible stack, // so we must NULL out values as we clear them. @@ -1239,8 +1241,6 @@ _Py_BuildString_StackRefSteal( return res; } - - PyObject * _Py_BuildMap_StackRefSteal( _PyStackRef *arguments, @@ -1257,6 +1257,8 @@ _Py_BuildMap_StackRefSteal( args_o+1, 2, half_args ); + STACKREFS_TO_PYOBJECTS_CLEANUP(args_o); + assert((res != NULL) ^ (PyErr_Occurred() != NULL)); cleanup: // arguments is a pointer into the GC visible stack, // so we must NULL out values as we clear them.