Skip to content

Commit 1367a45

Browse files
committed
fixed: #179
Out of bounds write on `Array.insert` when array is at capacity.
1 parent 4b940e5 commit 1367a45

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

core/container/array.onyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,12 +165,12 @@ Array.insert :: (arr: &[..] $T, idx: u32, x: T) -> bool {
165165
if idx > arr.count do return false;
166166
if !Array.ensure_capacity(arr, arr.count + 1) do return false;
167167

168-
arr.count += 1;
169168
while i := arr.count; i > idx {
170169
arr.data[i] = arr.data[i - 1];
171170
i -= 1;
172171
}
173172

173+
arr.count += 1;
174174
arr.data[idx] = x;
175175
return true;
176176
}

0 commit comments

Comments
 (0)