Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ml-proto/spec/check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ and check_has_memory c at =

and check_memop memop at =
require (memop.offset >= 0L) at "negative offset";
require (memop.offset <= 0xffffffffL) at "offset too large";
Lib.Option.app
(fun a -> require (Lib.Int.is_power_of_two a) at "non-power-of-two alignment")
memop.align
Expand Down
6 changes: 2 additions & 4 deletions ml-proto/test/address.wast
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,14 @@
)
(export "good" $good)

(func $bad1 (param $i i32) (i32.load offset=4294967296 (get_local $i)))
(export "bad1" $bad1)
(func $bad2 (param $i i32) (i32.load offset=4294967295 (get_local $i)))
(export "bad2" $bad2)
)

(assert_return (invoke "good" (i32.const 0)))
(assert_return (invoke "good" (i32.const 995)))
(assert_trap (invoke "good" (i32.const 996)) "out of bounds memory access")
(assert_trap (invoke "bad1" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "bad1" (i32.const 1)) "out of bounds memory access")
(assert_trap (invoke "bad2" (i32.const 0)) "out of bounds memory access")
(assert_trap (invoke "bad2" (i32.const 1)) "out of bounds memory access")

(assert_invalid (module (memory 1024) (func $bad1 (param $i i32) (i32.load offset=4294967296 (get_local $i))) ) "offset too large")