Skip to content

Commit e3b2db8

Browse files
xclercsmorimoto
authored andcommitted
Strengthen bound checks.
1 parent c7f9b26 commit e3b2db8

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compiler/lib/eval.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,8 @@ let eval_branch info = function
311311
Meanwhile, add guards to prevent Invalid_argument("index out of bounds")
312312
see https://github.com/ocsigen/js_of_ocaml/issues/485 *)
313313
match the_case_of info (Pv x) with
314-
| CConst j when j < Array.length const -> Branch const.(j)
315-
| CTag j when j < Array.length tags -> Branch tags.(j)
314+
| CConst j when j >= 0 && j < Array.length const -> Branch const.(j)
315+
| CTag j when j >= 0 && j < Array.length tags -> Branch tags.(j)
316316
| CConst _ | CTag _ | Unknown -> b)
317317
| _ as b -> b
318318

0 commit comments

Comments
 (0)