|
158 | 158 | (array.new_data $vec $d (i32.const 1) (i32.const 3))
|
159 | 159 | )
|
160 | 160 |
|
| 161 | + (func $new-overflow (export "new-overflow") (result (ref $vec)) |
| 162 | + (array.new_data $vec $d (i32.const 0x8000_0000) (i32.const 0x8000_0000)) |
| 163 | + ) |
| 164 | + |
161 | 165 | (func $get_u (param $i i32) (param $v (ref $vec)) (result i32)
|
162 | 166 | (array.get_u $vec (local.get $v) (local.get $i))
|
163 | 167 | )
|
|
189 | 193 | (func (export "len") (result i32)
|
190 | 194 | (call $len (call $new))
|
191 | 195 | )
|
| 196 | + |
| 197 | + (func (export "drop_segs") |
| 198 | + (data.drop $d) |
| 199 | + ) |
192 | 200 | )
|
193 | 201 |
|
194 | 202 | (assert_return (invoke "new") (ref.array))
|
|
198 | 206 | (assert_return (invoke "set_get" (i32.const 1) (i32.const 7)) (i32.const 7))
|
199 | 207 | (assert_return (invoke "len") (i32.const 3))
|
200 | 208 |
|
| 209 | +(assert_trap (invoke "new-overflow") "out of bounds memory access") |
201 | 210 | (assert_trap (invoke "get_u" (i32.const 10)) "out of bounds array access")
|
202 | 211 | (assert_trap (invoke "get_s" (i32.const 10)) "out of bounds array access")
|
203 | 212 | (assert_trap (invoke "set_get" (i32.const 10) (i32.const 7)) "out of bounds array access")
|
204 | 213 |
|
| 214 | +(assert_return (invoke "drop_segs")) |
| 215 | + |
| 216 | +(assert_trap (invoke "new") "out of bounds memory access") |
| 217 | +(assert_trap (invoke "new-overflow") "out of bounds memory access") |
| 218 | + |
205 | 219 | (module
|
206 | 220 | (type $bvec (array i8))
|
207 | 221 | (type $vec (array (ref $bvec)))
|
|
218 | 232 | (array.new_elem $vec $e (i32.const 0) (i32.const 2))
|
219 | 233 | )
|
220 | 234 |
|
| 235 | + (func $new-overflow (export "new-overflow") (result (ref $vec)) |
| 236 | + (array.new_elem $vec $e (i32.const 0x8000_0000) (i32.const 0x8000_0000)) |
| 237 | + ) |
| 238 | + |
221 | 239 | (func $sub1 (result (ref $nvec))
|
222 | 240 | (array.new_elem $nvec $e (i32.const 0) (i32.const 2))
|
223 | 241 | )
|
|
249 | 267 | (func (export "len") (result i32)
|
250 | 268 | (call $len (call $new))
|
251 | 269 | )
|
| 270 | + |
| 271 | + (func (export "drop_segs") |
| 272 | + (elem.drop $e) |
| 273 | + ) |
252 | 274 | )
|
253 | 275 |
|
254 | 276 | (assert_return (invoke "new") (ref.array))
|
|
258 | 280 | (assert_return (invoke "set_get" (i32.const 0) (i32.const 1) (i32.const 1)) (i32.const 2))
|
259 | 281 | (assert_return (invoke "len") (i32.const 2))
|
260 | 282 |
|
| 283 | +(assert_trap (invoke "new-overflow") "out of bounds table access") |
261 | 284 | (assert_trap (invoke "get" (i32.const 10) (i32.const 0)) "out of bounds array access")
|
262 | 285 | (assert_trap (invoke "set_get" (i32.const 10) (i32.const 0) (i32.const 0)) "out of bounds array access")
|
263 | 286 |
|
| 287 | +(assert_return (invoke "drop_segs")) |
| 288 | + |
| 289 | +(assert_trap (invoke "new") "out of bounds table access") |
| 290 | +(assert_trap (invoke "new-overflow") "out of bounds table access") |
| 291 | + |
264 | 292 | (assert_invalid
|
265 | 293 | (module
|
266 | 294 | (type $a (array i64))
|
|
0 commit comments