Skip to content

Commit

Permalink
fix table.get out_of_bounds check (it's better to check before getting
Browse files Browse the repository at this point in the history
the value...)
  • Loading branch information
zapashcanon committed Sep 16, 2023
1 parent 84dcb86 commit 4c76595
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/interpret_functor.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1025,10 +1025,11 @@ module Make (P : Interpret_functor_intf.P) :
let i, stack = Stack.pop_i32 stack in
let/ i = Choice.select_i32 i in
let i = Int32.to_int i in
let v = Table.get t i in
let size = Table.size t in
if i < 0 || i >= size then Choice.trap Out_of_bounds_table_access
else st @@ Stack.push stack (Ref v)
else
let v = Table.get t i in
st @@ Stack.push stack (Ref v)
| Table_set indice ->
let* t = Env.get_table env indice in
let/ t in
Expand Down

0 comments on commit 4c76595

Please sign in to comment.