diff options
author | Mark Shannon <mark@hotpy.org> | 2025-01-22 10:51:37 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-01-22 10:51:37 +0000 |
commit | 470a0a68ebbbb4254f1a3e8e22cce0c3a0827055 (patch) | |
tree | 27f602ce33d9c7701db07ad64fb0342c8f49a65a /Python/bytecodes.c | |
parent | a65f802692bd04e1ad18e467d4ccb033b049c2a7 (diff) | |
download | cpython-470a0a68ebbbb4254f1a3e8e22cce0c3a0827055.tar.gz cpython-470a0a68ebbbb4254f1a3e8e22cce0c3a0827055.zip |
GH-128682: Change a couple of functions to only steal references on success. (GH-129132)
Change PyTuple_FromStackRefSteal and PyList_FromStackRefSteal to only steal on success to avoid escaping
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r-- | Python/bytecodes.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c index 8bed29ca2c8..c78d496adcd 100644 --- a/Python/bytecodes.c +++ b/Python/bytecodes.c @@ -1852,16 +1852,20 @@ dummy_func( } inst(BUILD_TUPLE, (values[oparg] -- tup)) { - PyObject *tup_o = _PyTuple_FromStackRefSteal(values, oparg); + PyObject *tup_o = _PyTuple_FromStackRefStealOnSuccess(values, oparg); + if (tup_o == NULL) { + ERROR_NO_POP(); + } INPUTS_DEAD(); - ERROR_IF(tup_o == NULL, error); tup = PyStackRef_FromPyObjectSteal(tup_o); } inst(BUILD_LIST, (values[oparg] -- list)) { - PyObject *list_o = _PyList_FromStackRefSteal(values, oparg); + PyObject *list_o = _PyList_FromStackRefStealOnSuccess(values, oparg); + if (list_o == NULL) { + ERROR_NO_POP(); + } INPUTS_DEAD(); - ERROR_IF(list_o == NULL, error); list = PyStackRef_FromPyObjectSteal(list_o); } |