From 77681badabb0f1a94a7d745aba376c534b2826d2 Mon Sep 17 00:00:00 2001 From: Stefan Behnel Date: Mon, 30 Oct 2023 07:09:52 +0100 Subject: [PATCH] gh-106168: 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. --- Include/cpython/listobject.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Include/cpython/listobject.h b/Include/cpython/listobject.h index 661610548733fd..c4d9052a09ef42 100644 --- a/Include/cpython/listobject.h +++ b/Include/cpython/listobject.h @@ -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) \