diff --git a/test/core/binary.wast b/test/core/binary.wast index d034e5fec9..3008e1e775 100644 --- a/test/core/binary.wast +++ b/test/core/binary.wast @@ -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