mirror of
https://github.com/python/cpython.git
synced 2025-08-22 17:55:18 +00:00
gh-117139: Fix an incorrect borrow in bytecodes.c (#122318)
`_PyDict_SetItem_Take2` steals both the key (i.e., `sub`) and the value.
This commit is contained in:
parent
013a092975
commit
674a50ef2f
3 changed files with 14 additions and 11 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue