From 1367a45ba0d6e680e9f25451a07a563aeb4de3e7 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Thu, 26 Dec 2024 17:09:02 -0600 Subject: [PATCH] fixed: #179 Out of bounds write on `Array.insert` when array is at capacity. --- core/container/array.onyx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/container/array.onyx b/core/container/array.onyx index 62326f39..aa59bae7 100644 --- a/core/container/array.onyx +++ b/core/container/array.onyx @@ -165,12 +165,12 @@ Array.insert :: (arr: &[..] $T, idx: u32, x: T) -> bool { if idx > arr.count do return false; if !Array.ensure_capacity(arr, arr.count + 1) do return false; - arr.count += 1; while i := arr.count; i > idx { arr.data[i] = arr.data[i - 1]; i -= 1; } + arr.count += 1; arr.data[idx] = x; return true; }