From a2d2916e3220ec333122afb9cdef0f5c1eda84f7 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Wed, 16 Apr 2025 00:09:57 -0400 Subject: Fixes to get the compiler to build with -O3 --- src/stdlib/lists.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/stdlib/lists.c') diff --git a/src/stdlib/lists.c b/src/stdlib/lists.c index af0d1e0a..f5be09e9 100644 --- a/src/stdlib/lists.c +++ b/src/stdlib/lists.c @@ -76,11 +76,15 @@ public void List$insert(List_t *list, const void *item, Int_t int_index, int64_t list->data_refcount = 0; list->stride = padded_item_size; } else { - if (index != list->length+1) + if (index != list->length+1) { + assert(list->length >= index); + size_t size = (size_t)((list->length - index + 1)*padded_item_size); + assert(size < SIZE_MAX); memmove( list->data + index*padded_item_size, list->data + (index-1)*padded_item_size, - (size_t)((list->length - index + 1)*padded_item_size)); + size); + } } assert(list->free > 0); --list->free; -- cgit v1.2.3