]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
GH-139757: Fix reference leaks introduced in GH-140800 (GH-142257)
authorMark Shannon <mark@hotpy.org>
Thu, 4 Dec 2025 12:27:15 +0000 (12:27 +0000)
committerGitHub <noreply@github.com>
Thu, 4 Dec 2025 12:27:15 +0000 (12:27 +0000)
Python/ceval.c

index 1709dda0cbe1452ff4c22e3a125fc6e974b5023e..46bf644106ac39601384d1c0e64f5dd9f18ea770 100644 (file)
@@ -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 @@ cleanup:
     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.