diff --git a/interpreter/binary/decode.ml b/interpreter/binary/decode.ml index 78b4667766..7ed4a9235e 100644 --- a/interpreter/binary/decode.ml +++ b/interpreter/binary/decode.ml @@ -110,7 +110,7 @@ let v128 s = V128.of_bits (get_string (Types.vec_size Types.V128Type) s) let len32 s = let pos = pos s in let n = vu32 s in - if I32.le_u n (Int32.of_int (len s)) then Int32.to_int n else + if I32.le_u n (Int32.of_int (len s - pos)) then Int32.to_int n else error s pos "length out of bounds" let bool s = (vu1 s = 1) diff --git a/test/core/binary.wast b/test/core/binary.wast index e80d3e20b5..31bb24a937 100644 --- a/test/core/binary.wast +++ b/test/core/binary.wast @@ -1311,7 +1311,7 @@ "\60\00\00" ;; 1st type ;; "\60\00\00" ;; 2nd type (missed) ) - "unexpected end of section or function" + "length out of bounds" ) ;; 1 type declared, 2 given @@ -1600,7 +1600,7 @@ "\02\00\0b" ;; function body 0 "\02\00\0b" ;; function body 1 ) - "unexpected end of section or function" + "length out of bounds" ) ;; 1 export declared, 2 given @@ -1662,7 +1662,7 @@ "\03\02\01\00" ;; func section "\04\04\01" ;; table section "\70\00\01" ;; table 0 - "\09\07\02" ;; elem with inconsistent segment count (2 declared, 1 given) + "\09\0a\02" ;; elem with inconsistent segment count (2 declared, 1 given) "\00\41\00\0b\01\00" ;; elem 0 "\00\41\00" ;; elem 1 (partial) ;; "\0b\01\00" ;; elem 1 (missing part) @@ -1774,7 +1774,7 @@ "\01\04\01" ;; type section "\60\00\00" ;; type 0 "\03\02\01\00" ;; func section - "\0a\12\01" ;; code section + "\0a\13\01" ;; code section "\11\00" ;; func 0 "\02\40" ;; block 0 "\41\01" ;; condition of if 0 diff --git a/test/core/custom.wast b/test/core/custom.wast index b2394f5e3b..12b0476503 100644 --- a/test/core/custom.wast +++ b/test/core/custom.wast @@ -86,7 +86,7 @@ "\00asm" "\01\00\00\00" "\00\26\10" "a custom section" "this is the payload" ) - "unexpected end" + "length out of bounds" ) (assert_malformed