From c68bebfd7c6fb6a220c5b897c8e8abc073a72c0e Mon Sep 17 00:00:00 2001 From: klemek Date: Sat, 16 May 2026 13:25:02 +0200 Subject: [PATCH] fix: unsigned underflow on empty array --- src/arr.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arr.c b/src/arr.c index baf4020..8d47356 100644 --- a/src/arr.c +++ b/src/arr.c @@ -13,6 +13,10 @@ unsigned int arr_uint_index_of(UintArray array, unsigned int value) { } unsigned int arr_uint_remap_index(UintArray offsets, unsigned int *index) { + if (offsets.length == 0) { + return 0; + } + for (unsigned int i = offsets.length - 1; i > 0; i--) { if (*index >= offsets.values[i]) { *index -= offsets.values[i];