Skip to content

Commit 66d90a7

Browse files
authored
Test that partially out of bounds segments don't write to a memory/table (WebAssembly#139)
Fixes WebAssembly#138
1 parent 996ef3f commit 66d90a7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

test/core/linking.wast

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,11 +231,12 @@
231231
(table (import "Mt" "tab") 10 funcref)
232232
(func $f (result i32) (i32.const 0))
233233
(elem (i32.const 7) $f)
234-
(elem (i32.const 12) $f) ;; out of bounds
234+
(elem (i32.const 8) $f $f $f $f $f) ;; (partially) out of bounds
235235
)
236236
"out of bounds"
237237
)
238238
(assert_return (invoke $Mt "call" (i32.const 7)) (i32.const 0))
239+
(assert_trap (invoke $Mt "call" (i32.const 8)) "uninitialized")
239240

240241
(assert_trap
241242
(module
@@ -337,13 +338,15 @@
337338
;; after the instantiation failure.
338339
(assert_trap
339340
(module
341+
;; Note: the memory is 5 pages large by the time we get here.
340342
(memory (import "Mm" "mem") 1)
341343
(data (i32.const 0) "abc")
342-
(data (i32.const 0x50000) "d") ;; out of bounds
344+
(data (i32.const 327670) "zzzzzzzzzzzzzzzzzz") ;; (partially) out of bounds
343345
)
344346
"out of bounds"
345347
)
346348
(assert_return (invoke $Mm "load" (i32.const 0)) (i32.const 97))
349+
(assert_return (invoke $Mm "load" (i32.const 327670)) (i32.const 0))
347350

348351
(assert_trap
349352
(module

0 commit comments

Comments
 (0)