Skip to content

Commit fcbaaae

Browse files
committed
Vec: fix bound check error
1 parent 6c8d684 commit fcbaaae

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/util/Vec.ml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,12 @@ let[@inline] get t i =
7373
Array.unsafe_get t.data i
7474

7575
let[@inline] set t i v =
76-
if i < 0 || i > t.sz then invalid_arg "vec.set";
7776
if i = t.sz then
7877
push t v
79-
else
78+
else if i >= 0 && i < t.sz then
8079
Array.unsafe_set t.data i v
80+
else
81+
invalid_arg "vec.set"
8182

8283
let[@inline] fast_remove t i =
8384
assert (i >= 0 && i < t.sz);

0 commit comments

Comments
 (0)