mirror of
https://github.com/python/cpython.git
synced 2025-11-01 02:38:53 +00:00
gh-106168: PyTuple_SET_ITEM() now checks the index (#106164)
PyTuple_SET_ITEM() and PyList_SET_ITEM() now check the index argument with an assertion if Python is built in debug mode or is built with assertions. * list_extend() and _PyList_AppendTakeRef() now set the list size before calling PyList_SET_ITEM(). * PyStructSequence_GetItem() and PyStructSequence_SetItem() now check the index argument: must be lesser than REAL_SIZE(op). * PyStructSequence_GET_ITEM() and PyStructSequence_SET_ITEM() are now aliases to PyStructSequence_GetItem() and PyStructSequence_SetItem().
This commit is contained in:
parent
161012fc25
commit
3f8483cad2
10 changed files with 63 additions and 24 deletions
|
|
@ -49,8 +49,8 @@ _PyList_AppendTakeRef(PyListObject *self, PyObject *newitem)
|
|||
Py_ssize_t allocated = self->allocated;
|
||||
assert((size_t)len + 1 < PY_SSIZE_T_MAX);
|
||||
if (allocated > len) {
|
||||
PyList_SET_ITEM(self, len, newitem);
|
||||
Py_SET_SIZE(self, len + 1);
|
||||
PyList_SET_ITEM(self, len, newitem);
|
||||
return 0;
|
||||
}
|
||||
return _PyList_AppendTakeRefListResize(self, newitem);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue