Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 2 additions & 3 deletions src/wasm-interpreter.h
Original file line number Diff line number Diff line change
Expand Up @@ -1986,6 +1986,7 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
if (ref.breaking()) {
return ref;
}
// TODO: "WTF-16 position treatment", as in stringview_wtf16.slice?
Flow ptr = visit(curr->ptr);
if (ptr.breaking()) {
return ptr;
Expand Down Expand Up @@ -2173,9 +2174,7 @@ class ExpressionRunner : public OverriddenVisitor<SubType, Flow> {
auto& refValues = refData->values;
auto startVal = start.getSingleValue().getUnsigned();
auto endVal = end.getSingleValue().getUnsigned();
if (endVal > refValues.size()) {
trap("array oob");
}
endVal = std::min<size_t>(endVal, refValues.size());
if (hasNonAsciiUpTo(refValues, endVal)) {
return Flow(NONCONSTANT_FLOW);
}
Expand Down
15 changes: 15 additions & 0 deletions test/lit/exec/strings.wast
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,17 @@
(i32.const 6)
)
)

;; CHECK: [fuzz-exec] calling slice-big
;; CHECK-NEXT: [fuzz-exec] note result: slice-big => string("defgh")
(func $slice-big (export "slice-big") (result (ref string))
;; Slicing [3:huge unsigned value] leads to slicing til the end: "defgh".
(stringview_wtf16.slice
(string.const "abcdefgh")
(i32.const 3)
(i32.const -1)
)
)
)
;; CHECK: [fuzz-exec] calling new_wtf16_array
;; CHECK-NEXT: [fuzz-exec] note result: new_wtf16_array => string("ello")
Expand Down Expand Up @@ -323,6 +334,9 @@

;; CHECK: [fuzz-exec] calling slice
;; CHECK-NEXT: [fuzz-exec] note result: slice => string("def")

;; CHECK: [fuzz-exec] calling slice-big
;; CHECK-NEXT: [fuzz-exec] note result: slice-big => string("defgh")
;; CHECK-NEXT: [fuzz-exec] comparing compare.1
;; CHECK-NEXT: [fuzz-exec] comparing compare.10
;; CHECK-NEXT: [fuzz-exec] comparing compare.2
Expand All @@ -344,3 +358,4 @@
;; CHECK-NEXT: [fuzz-exec] comparing get_length
;; CHECK-NEXT: [fuzz-exec] comparing new_wtf16_array
;; CHECK-NEXT: [fuzz-exec] comparing slice
;; CHECK-NEXT: [fuzz-exec] comparing slice-big