Skip to content

Commit 6825d5c

Browse files
authored
GH-139757: Fix reference leaks introduced in GH-140800 (GH-142257)
1 parent fb404ab commit 6825d5c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

Python/ceval.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1228,6 +1228,8 @@ _Py_BuildString_StackRefSteal(
12281228
goto cleanup;
12291229
}
12301230
res = _PyUnicode_JoinArray(&_Py_STR(empty), args_o, total_args);
1231+
STACKREFS_TO_PYOBJECTS_CLEANUP(args_o);
1232+
assert((res != NULL) ^ (PyErr_Occurred() != NULL));
12311233
cleanup:
12321234
// arguments is a pointer into the GC visible stack,
12331235
// so we must NULL out values as we clear them.
@@ -1239,8 +1241,6 @@ _Py_BuildString_StackRefSteal(
12391241
return res;
12401242
}
12411243

1242-
1243-
12441244
PyObject *
12451245
_Py_BuildMap_StackRefSteal(
12461246
_PyStackRef *arguments,
@@ -1257,6 +1257,8 @@ _Py_BuildMap_StackRefSteal(
12571257
args_o+1, 2,
12581258
half_args
12591259
);
1260+
STACKREFS_TO_PYOBJECTS_CLEANUP(args_o);
1261+
assert((res != NULL) ^ (PyErr_Occurred() != NULL));
12601262
cleanup:
12611263
// arguments is a pointer into the GC visible stack,
12621264
// so we must NULL out values as we clear them.

0 commit comments

Comments
 (0)