summaryrefslogtreecommitdiff
path: root/test/lit/exec
diff options
context:
space:
mode:
authorAlon Zakai <azakai@google.com>2024-04-01 14:15:26 -0700
committerGitHub <noreply@github.com>2024-04-01 14:15:26 -0700
commitf984324d06e3024f742c7fe9c26aac5bbebe3c71 (patch)
tree857b68954fb51eadd2edb08c545fae14d3562038 /test/lit/exec
parentfedee9fb559e06db94eb5ae565914d59df5db315 (diff)
downloadbinaryen-f984324d06e3024f742c7fe9c26aac5bbebe3c71.tar.gz
binaryen-f984324d06e3024f742c7fe9c26aac5bbebe3c71.tar.bz2
binaryen-f984324d06e3024f742c7fe9c26aac5bbebe3c71.zip
[Strings] string.new_wtf16_array should trap if the end index is less than the start (#6459)
Diffstat (limited to 'test/lit/exec')
-rw-r--r--test/lit/exec/strings.wast69
1 files changed, 69 insertions, 0 deletions
diff --git a/test/lit/exec/strings.wast b/test/lit/exec/strings.wast
index 4fb17a9e3..c67436c98 100644
--- a/test/lit/exec/strings.wast
+++ b/test/lit/exec/strings.wast
@@ -342,6 +342,59 @@
)
)
+ ;; CHECK: [fuzz-exec] calling new_oob
+ ;; CHECK-NEXT: [trap array oob]
+ (func $new_oob (export "new_oob") (result stringref)
+ ;; Try to make a string from an array of size 1 that we slice at [1:0],
+ ;; which is out of bounds due to the ending index (we must trap if the end
+ ;; is less then the start).
+ (string.new_wtf16_array
+ (array.new_default $array16
+ (i32.const 1)
+ )
+ (i32.const 1)
+ (i32.const 0)
+ )
+ )
+
+ ;; CHECK: [fuzz-exec] calling new_2
+ ;; CHECK-NEXT: [fuzz-exec] note result: new_2 => string("")
+ (func $new_2 (export "new_2") (result stringref)
+ (string.new_wtf16_array
+ (array.new_default $array16
+ (i32.const 1)
+ )
+ (i32.const 1)
+ (i32.const 1) ;; this changed, which makes this an in-bounds operation
+ ;; that emits an empty string
+ )
+ )
+
+ ;; CHECK: [fuzz-exec] calling new_oob_3
+ ;; CHECK-NEXT: [trap array oob]
+ (func $new_oob_3 (export "new_oob_3") (result stringref)
+ (string.new_wtf16_array
+ (array.new_default $array16
+ (i32.const 1)
+ )
+ (i32.const 1)
+ (i32.const 2) ;; this changed, and again we are out of bounds
+ )
+ )
+
+ ;; CHECK: [fuzz-exec] calling new_4
+ ;; CHECK-NEXT: [fuzz-exec] note result: new_4 => string("\u0000")
+ (func $new_4 (export "new_4") (result stringref)
+ (string.new_wtf16_array
+ (array.new_default $array16
+ (i32.const 2) ;; this changed, and now we are in bounds, and emit a
+ ;; string of length 1 (with unicode 0)
+ )
+ (i32.const 1)
+ (i32.const 2)
+ )
+ )
+
;; CHECK: [fuzz-exec] calling slice-unicode
;; CHECK-NEXT: [fuzz-exec] note result: slice-unicode => string("d\u00a3f")
(func $slice-unicode (export "slice-unicode") (result (ref string))
@@ -448,6 +501,18 @@
;; CHECK: [fuzz-exec] calling new_empty_oob_2
;; CHECK-NEXT: [trap array oob]
+;; CHECK: [fuzz-exec] calling new_oob
+;; CHECK-NEXT: [trap array oob]
+
+;; CHECK: [fuzz-exec] calling new_2
+;; CHECK-NEXT: [fuzz-exec] note result: new_2 => string("")
+
+;; CHECK: [fuzz-exec] calling new_oob_3
+;; CHECK-NEXT: [trap array oob]
+
+;; CHECK: [fuzz-exec] calling new_4
+;; CHECK-NEXT: [fuzz-exec] note result: new_4 => string("\u0000")
+
;; CHECK: [fuzz-exec] calling slice-unicode
;; CHECK-NEXT: [fuzz-exec] note result: slice-unicode => string("d\u00a3f")
@@ -475,9 +540,13 @@
;; CHECK-NEXT: [fuzz-exec] comparing eq.5
;; CHECK-NEXT: [fuzz-exec] comparing get_codeunit
;; CHECK-NEXT: [fuzz-exec] comparing get_length
+;; CHECK-NEXT: [fuzz-exec] comparing new_2
+;; CHECK-NEXT: [fuzz-exec] comparing new_4
;; CHECK-NEXT: [fuzz-exec] comparing new_empty
;; CHECK-NEXT: [fuzz-exec] comparing new_empty_oob
;; CHECK-NEXT: [fuzz-exec] comparing new_empty_oob_2
+;; CHECK-NEXT: [fuzz-exec] comparing new_oob
+;; CHECK-NEXT: [fuzz-exec] comparing new_oob_3
;; CHECK-NEXT: [fuzz-exec] comparing new_wtf16_array
;; CHECK-NEXT: [fuzz-exec] comparing slice
;; CHECK-NEXT: [fuzz-exec] comparing slice-big