8000 gh-106168: Check allocated instead of size index bounds in PyList_SET… · python/cpython@940ee96 · GitHub
[go: up one dir, main page]

Skip to content

Commit 940ee96

Browse files
authored
gh-106168: Check allocated instead of size index bounds in PyList_SET_ITEM() (#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.
1 parent 4a929d4 commit 940ee96

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Include/cpython/listobject.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ static inline void
3939
PyList_SET_ITEM(PyObject *op, Py_ssize_t index, PyObject *value) {
4040
PyListObject *list = _PyList_CAST(op);
4141
assert(0 <= index);
42-
assert(index < Py_SIZE(list));
42+
assert(index < list->allocated);
4343
list->ob_item[index] = value;
4444
}
4545
#define PyList_SET_ITEM(op, index, value) \

0 commit comments

Comments
 (0)
0