Skip to content

Commit

Permalink
pythongh-106168: Check allocated instead of size index bounds in PyLi…
Browse files Browse the repository at this point in the history
…st_SET_ITEM() (python#111480)

Check the index bound assertions in PyList_SET_ITEM() against [0:allocated] instead of [0:size] to re-allow valid use cases that assign within the allocated area.
  • Loading branch information
scoder authored and Glyphack committed Jan 27, 2024
1 parent 1608a04 commit 0f86605
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Include/cpython/listobject.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ static inline void
PyList_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
PyListObject *list = _PyList_CAST(op);
assert(0 <= index);
assert(index < Py_SIZE(list));
assert(index < list->allocated);
list->ob_item[index] = value;
}
#define PyList_SET_ITEM(op, index, value) \
Expand Down

0 comments on commit 0f86605

Please sign in to comment.