Skip to content

Commit 5257f13

Browse files
authored
[test] Fix section size in binary test (WebAssembly#1424)
1 parent 5a6a7fb commit 5257f13

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

interpreter/binary/decode.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ let v128 s = V128.of_bits (get_string (Types.vec_size Types.V128Type) s)
110110
let len32 s =
111111
let pos = pos s in
112112
let n = vu32 s in
113-
if I32.le_u n (Int32.of_int (len s)) then Int32.to_int n else
113+
if I32.le_u n (Int32.of_int (len s - pos)) then Int32.to_int n else
114114
error s pos "length out of bounds"
115115

116116
let bool s = (vu1 s = 1)

test/core/binary.wast

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1311,7 +1311,7 @@
13111311
"\60\00\00" ;; 1st type
13121312
;; "\60\00\00" ;; 2nd type (missed)
13131313
)
1314-
"unexpected end of section or function"
1314+
"length out of bounds"
13151315
)
13161316

13171317
;; 1 type declared, 2 given
@@ -1600,7 +1600,7 @@
16001600
"\02\00\0b" ;; function body 0
16011601
"\02\00\0b" ;; function body 1
16021602
)
1603-
"unexpected end of section or function"
1603+
"length out of bounds"
16041604
)
16051605

16061606
;; 1 export declared, 2 given
@@ -1662,7 +1662,7 @@
16621662
"\03\02\01\00" ;; func section
16631663
"\04\04\01" ;; table section
16641664
"\70\00\01" ;; table 0
1665-
"\09\07\02" ;; elem with inconsistent segment count (2 declared, 1 given)
1665+
"\09\0a\02" ;; elem with inconsistent segment count (2 declared, 1 given)
16661666
"\00\41\00\0b\01\00" ;; elem 0
16671667
"\00\41\00" ;; elem 1 (partial)
16681668
;; "\0b\01\00" ;; elem 1 (missing part)
@@ -1774,7 +1774,7 @@
17741774
"\01\04\01" ;; type section
17751775
"\60\00\00" ;; type 0
17761776
"\03\02\01\00" ;; func section
1777-
"\0a\12\01" ;; code section
1777+
"\0a\13\01" ;; code section
17781778
"\11\00" ;; func 0
17791779
"\02\40" ;; block 0
17801780
"\41\01" ;; condition of if 0

test/core/custom.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@
8686
"\00asm" "\01\00\00\00"
8787
"\00\26\10" "a custom section" "this is the payload"
8888
)
89-
"unexpected end"
89+
"length out of bounds"
9090
)
9191

9292
(assert_malformed

0 commit comments

Comments
 (0)