Skip to content

Commit

Permalink
fixed: #179
Browse files Browse the repository at this point in the history
Out of bounds write on `Array.insert` when array is at capacity.
  • Loading branch information
brendanfh committed Dec 26, 2024
1 parent 4b940e5 commit 1367a45
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion core/container/array.onyx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 1367a45

Please sign in to comment.