File tree Expand file tree Collapse file tree 7 files changed +31
-13
lines changed Expand file tree Collapse file tree 7 files changed +31
-13
lines changed Original file line number Diff line number Diff line change @@ -195,4 +195,3 @@ let eval_binop = op I32Op.binop I64Op.binop F32Op.binop F64Op.binop
195
195
let eval_testop = op I32Op. testop I64Op. testop F32Op. testop F64Op. testop
196
196
let eval_relop = op I32Op. relop I64Op. relop F32Op. relop F64Op. relop
197
197
let eval_cvtop = op I32CvtOp. cvtop I64CvtOp. cvtop F32CvtOp. cvtop F64CvtOp. cvtop
198
-
Original file line number Diff line number Diff line change @@ -477,7 +477,7 @@ let to_hex_string s =
477
477
478
478
let of_strings shape ss =
479
479
if List. length ss <> num_lanes shape then
480
- raise ( Invalid_argument " wrong length" ) ;
480
+ invalid_arg " wrong length" ;
481
481
let open Bytes in
482
482
let b = create bytewidth in
483
483
(match shape with
Original file line number Diff line number Diff line change 1
1
type data = string ref
2
2
type t = data
3
3
4
+ exception Bounds
5
+
4
6
let alloc bs = ref bs
7
+
5
8
let size seg = I64. of_int_u (String. length ! seg)
6
- let load seg i = (! seg).[Int64. to_int i]
9
+
10
+ let load seg i =
11
+ let i' = Int64. to_int i in
12
+ if i' < 0 || i' > = String. length ! seg then raise Bounds ;
13
+ ! seg.[i']
14
+
7
15
let drop seg = seg := " "
Original file line number Diff line number Diff line change 1
1
type elem = Values .ref_ list ref
2
2
type t = elem
3
3
4
+ exception Bounds
5
+
4
6
let alloc rs = ref rs
5
7
let size seg = Lib.List32. length ! seg
6
- let load seg i = Lib.List32. nth ! seg i
8
+
9
+ let load seg i =
10
+ if i < 0l || i > = Lib.List32. length ! seg then raise Bounds ;
11
+ Lib.List32. nth ! seg i
12
+
7
13
let drop seg = seg := []
Original file line number Diff line number Diff line change @@ -62,10 +62,12 @@ let grow mem delta =
62
62
mem.content < - after
63
63
64
64
let load_byte mem a =
65
- try Array1_64. get mem.content a with Invalid_argument _ -> raise Bounds
65
+ if a < 0L || a > = Array1_64. dim mem.content then raise Bounds ;
66
+ Array1_64. get mem.content a
66
67
67
68
let store_byte mem a b =
68
- try Array1_64. set mem.content a b with Invalid_argument _ -> raise Bounds
69
+ if a < 0L || a > = Array1_64. dim mem.content then raise Bounds ;
70
+ Array1_64. set mem.content a b
69
71
70
72
let load_bytes mem a n =
71
73
let buf = Buffer. create n in
Original file line number Diff line number Diff line change @@ -47,14 +47,17 @@ let grow tab delta r =
47
47
tab.content < - after
48
48
49
49
let load tab i =
50
- try Lib.Array32. get tab.content i with Invalid_argument _ -> raise Bounds
50
+ if i < 0l || i > = Lib.Array32. length tab.content then raise Bounds ;
51
+ Lib.Array32. get tab.content i
51
52
52
53
let store tab i r =
53
54
let TableType (lim, t) = tab.ty in
54
55
if type_of_ref r <> t then raise Type ;
55
- try Lib.Array32. set tab.content i r with Invalid_argument _ -> raise Bounds
56
+ if i < 0l || i > = Lib.Array32. length tab.content then raise Bounds ;
57
+ Lib.Array32. set tab.content i r
56
58
57
59
let blit tab offset rs =
58
60
let data = Array. of_list rs in
59
- try Lib.Array32. blit data 0l tab.content offset (Lib.Array32. length data)
60
- with Invalid_argument _ -> raise Bounds
61
+ let len = Lib.Array32. length data in
62
+ if offset < 0l || offset > Int32. sub (Lib.Array32. length tab.content) len then raise Bounds ;
63
+ Lib.Array32. blit data 0l tab.content offset len
Original file line number Diff line number Diff line change @@ -156,7 +156,7 @@ module Array32 =
156
156
struct
157
157
let make n x =
158
158
if n < 0l || Int64. of_int32 n > Int64. of_int max_int then
159
- raise ( Invalid_argument " Array32.make" ) ;
159
+ invalid_arg " Array32.make" ;
160
160
Array. make (Int32. to_int n) x
161
161
162
162
let length a = Int32. of_int (Array. length a)
@@ -179,7 +179,7 @@ struct
179
179
struct
180
180
let create kind layout n =
181
181
if n < 0L || n > Int64. of_int max_int then
182
- raise ( Invalid_argument " Bigarray.Array1_64.create" ) ;
182
+ invalid_arg " Bigarray.Array1_64.create" ;
183
183
Array1. create kind layout (Int64. to_int n)
184
184
185
185
let dim a = Int64. of_int (Array1. dim a)
@@ -204,7 +204,7 @@ struct
204
204
let force o =
205
205
match o with
206
206
| Some y -> y
207
- | None -> raise ( Invalid_argument " Option.force" )
207
+ | None -> invalid_arg " Option.force"
208
208
209
209
let map f = function
210
210
| Some x -> Some (f x)
You can’t perform that action at this time.
0 commit comments