aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/bytecodes.c
diff options
context:
space:
mode:
authorSam Gross <colesbury@gmail.com>2024-08-07 09:36:19 -0400
committerGitHub <noreply@github.com>2024-08-07 19:06:19 +0530
commit674a50ef2f8909c1c5d812e166bcc12ae6377908 (patch)
tree3903df98dc42864af8fc51c11b1d0507280ce267 /Python/bytecodes.c
parent013a0929750ed2b46ae990b59d02e3db84337474 (diff)
downloadcpython-674a50ef2f8909c1c5d812e166bcc12ae6377908.tar.gz
cpython-674a50ef2f8909c1c5d812e166bcc12ae6377908.zip
gh-117139: Fix an incorrect borrow in bytecodes.c (#122318)
`_PyDict_SetItem_Take2` steals both the key (i.e., `sub`) and the value.
Diffstat (limited to 'Python/bytecodes.c')
-rw-r--r--Python/bytecodes.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/Python/bytecodes.c b/Python/bytecodes.c
index 9a1af0e9201..e4c97dee1f8 100644
--- a/Python/bytecodes.c
+++ b/Python/bytecodes.c
@@ -862,13 +862,14 @@ dummy_func(
PyStackRef_CLOSE(list_st);
}
- inst(STORE_SUBSCR_DICT, (unused/1, value, dict_st, sub_st -- )) {
- PyObject *sub = PyStackRef_AsPyObjectBorrow(sub_st);
+ inst(STORE_SUBSCR_DICT, (unused/1, value, dict_st, sub -- )) {
PyObject *dict = PyStackRef_AsPyObjectBorrow(dict_st);
DEOPT_IF(!PyDict_CheckExact(dict));
STAT_INC(STORE_SUBSCR, hit);
- int err = _PyDict_SetItem_Take2((PyDictObject *)dict, sub, PyStackRef_AsPyObjectSteal(value));
+ int err = _PyDict_SetItem_Take2((PyDictObject *)dict,
+ PyStackRef_AsPyObjectSteal(sub),
+ PyStackRef_AsPyObjectSteal(value));
PyStackRef_CLOSE(dict_st);
ERROR_IF(err, error);
}