Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
fix
  • Loading branch information
kripken committed Mar 25, 2024
commit a08d8aae7b04eab6b4b2dea0e7729cbeed5bd3d7
2 changes: 1 addition & 1 deletion src/wasm-interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1883,7 +1883,7 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
const auto& ptrDataValues = ptrData->values;
size_t startVal = start.getSingleValue().getUnsigned();
size_t endVal = end.getSingleValue().getUnsigned();
if (endVal > ptrDataValues.size()) {
if (startVal || endVal > ptrDataValues.size()) {
trap("array oob");
}
Literals contents;
Expand Down
23 changes: 23 additions & 0 deletions test/lit/exec/strings.wast
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,29 @@
(i32.const -1)
)
)

(func $new_empty (export "new_empty") (result stringref)
;; Make an empty string from an empty array.
(string.new_wtf16_array
(array.new_default $array16
(i32.const 0)
)
(i32.const 0)
(i32.const 0)
)
)

(func $new_empty_oob (export "new_empty_oob") (result stringref)
;; Try to make a string from an empty array that we slice at [1:0], which is
;; out of bounds due to the starting index.
(string.new_wtf16_array
(array.new_default $array16
(i32.const 0)
)
(i32.const 1)
(i32.const 0)
)
)
)
;; CHECK: [fuzz-exec] calling new_wtf16_array
;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello")
Expand Down