Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c022fb1

Browse files
authored
[test] Test that 0xff is treated as an invalid opcode (#1910)
1 parent a7b7ac5 commit c022fb1

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

test/core/binary.wast

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,3 +1208,25 @@
12081208
"unexpected content after last section"
12091209
)
12101210

1211+
;; The byte 0xff is documented as being a value that will not be used as
1212+
;; an instruction or instruction prefix opcode. Test that implementations
1213+
;; reject it. This test uses unreachable code in order to avoid
1214+
;; type-checking errors that might arise if 0xff were interpreted as an
1215+
;; instruction.
1216+
(assert_malformed
1217+
(module binary
1218+
"\00asm" "\01\00\00\00"
1219+
"\01\04\01\60\00\00" ;; Type section: 1 type
1220+
"\03\02\01\00" ;; Function section: 1 function
1221+
"\0a\08\01" ;; Code section: 1 function
1222+
;; function 0
1223+
"\06\00" ;; Function size and local type count
1224+
"\00" ;; unreachable
1225+
"\ff" ;; 0xff
1226+
"\00" ;; might be interpreted as unreachable, or as the second byte
1227+
;; of a multi-byte instruction
1228+
"\00" ;; unreachable
1229+
"\0b" ;; end
1230+
)
1231+
"illegal opcode ff"
1232+
)

0 commit comments

Comments
 (0)