The `list_preallocate_exact` function did not zero initialize array
contents. In the free-threaded build, this could expose uninitialized
memory to concurrent readers between the call to
`list_preallocate_exact` and the filling of the array contents with
items.
--- /dev/null
+Fix race condition in free-threaded build where :meth:`list.extend` could expose
+uninitialied memory to concurrent readers.
return -1;
}
items = array->ob_item;
+ memset(items, 0, size * sizeof(PyObject *));
#else
items = PyMem_New(PyObject*, size);
if (items == NULL) {
return -1;
}
#endif
- self->ob_item = items;
+ FT_ATOMIC_STORE_PTR_RELEASE(self->ob_item, items);
self->allocated = size;
return 0;
}