Skip to content

Commit

Permalink
Add tests for functions without end marker. NFC
Browse files Browse the repository at this point in the history
Inspired by this downstream test in wabt:
WebAssembly/wabt#1775

Fixes: #1404
  • Loading branch information
sbc100 committed Dec 13, 2021
1 parent 2460ad0 commit a73b049
Showing 1 changed file with 56 additions and 0 deletions.
56 changes: 56 additions & 0 deletions test/core/binary.wast
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,62 @@
"integer too large"
)

;; Function with missing end marker (between two functions)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\03\02\00\00" ;; Function section: 2 functions
"\0a\0c\02" ;; Code section: 2 functions
;; function 0
"\04\00" ;; Function size and local type count
"\41\01" ;; i32.const 1
"\1a" ;; drop
;; Missing end marker here
;; function 1
"\05\00" ;; Function size and local type count
"\41\01" ;; i32.const 1
"\1a" ;; drop
"\0b" ;; end
)
"END opcode expected"
)

;; Function with missing end marker (at EOF)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\0a\06\01" ;; Code section: 1 function
;; function 0
"\04\00" ;; Function size and local type count
"\41\01" ;; i32.const 1
"\1a" ;; drop
;; Missing end marker here
)
"unexpected end of section or function"
)

;; Function with missing end marker (at end of code sections)
(assert_malformed
(module binary
"\00asm" "\01\00\00\00"
"\01\04\01\60\00\00" ;; Type section: 1 type
"\03\02\01\00" ;; Function section: 1 function
"\0a\06\01" ;; Code section: 1 function
;; function 0
"\04\00" ;; Function size and local type count
"\41\01" ;; i32.const 1
"\1a" ;; drop
;; Missing end marker here
"\0b\03\01\01\00" ;; Data section
)
;; The spec interpreter consumes the `\0b` (data section start) as an
;; END instruction (also happens to be `\0b`) and reports the code section as
;; being larger than declared.
"section size mismatch"
)

;; Unsigned LEB128 must not be overlong
(assert_malformed
Expand Down

0 comments on commit a73b049

Please sign in to comment.