mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +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
|
@ -953,8 +953,9 @@ list_extend(PyListObject *self, PyObject *iterable)
|
|||
}
|
||||
if (Py_SIZE(self) < self->allocated) {
|
||||
/* steals ref */
|
||||
PyList_SET_ITEM(self, Py_SIZE(self), item);
|
||||
Py_SET_SIZE(self, Py_SIZE(self) + 1);
|
||||
Py_ssize_t len = Py_SIZE(self);
|
||||
Py_SET_SIZE(self, len + 1);
|
||||
PyList_SET_ITEM(self, len, item);
|
||||
}
|
||||
else {
|
||||
if (_PyList_AppendTakeRef(self, item) < 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue