Skip to content

Commit

Permalink
Test that partially out of bounds segments don't write to a memory/table
Browse files Browse the repository at this point in the history
  • Loading branch information
fitzgen committed Feb 26, 2020
1 parent 11388e7 commit f6d9954
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions test/core/linking.wast
Original file line number Diff line number Diff line change
Expand Up @@ -231,11 +231,12 @@
(table (import "Mt" "tab") 10 funcref)
(func $f (result i32) (i32.const 0))
(elem (i32.const 7) $f)
(elem (i32.const 12) $f) ;; out of bounds
(elem (i32.const 8) $f $f $f $f $f) ;; (partially) out of bounds
)
"out of bounds"
)
(assert_return (invoke $Mt "call" (i32.const 7)) (i32.const 0))
(assert_trap (invoke $Mt "call" (i32.const 8)) "uninitialized")

(assert_trap
(module
Expand Down Expand Up @@ -337,13 +338,15 @@
;; after the instantiation failure.
(assert_trap
(module
;; Note: the memory is 5 pages large by the time we get here.
(memory (import "Mm" "mem") 1)
(data (i32.const 0) "abc")
(data (i32.const 0x50000) "d") ;; out of bounds
(data (i32.const 327670) "zzzzzzzzzzzzzzzzzz") ;; (partially) out of bounds
)
"out of bounds"
)
(assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97))
(assert_return (invoke $Mm "load" (i32.const 327670)) (i32.const 0))

(assert_trap
(module
Expand Down

0 comments on commit f6d9954

Please sign in to comment.