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
195195let eval_testop = op I32Op. testop I64Op. testop F32Op. testop F64Op. testop
196196let eval_relop = op I32Op. relop I64Op. relop F32Op. relop F64Op. relop
197197let 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 =
477477
478478let of_strings shape ss =
479479 if List. length ss <> num_lanes shape then
480- raise ( Invalid_argument " wrong length" ) ;
480+ invalid_arg " wrong length" ;
481481 let open Bytes in
482482 let b = create bytewidth in
483483 (match shape with
Original file line number Diff line number Diff line change 11type data = string ref
22type t = data
33
4+ exception Bounds
5+
46let alloc bs = ref bs
7+
58let 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+
715let drop seg = seg := " "
Original file line number Diff line number Diff line change 11type elem = Values .ref_ list ref
22type t = elem
33
4+ exception Bounds
5+
46let alloc rs = ref rs
57let 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+
713let drop seg = seg := []
Original file line number Diff line number Diff line change @@ -62,10 +62,12 @@ let grow mem delta =
6262 mem.content < - after
6363
6464let 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
6667
6768let 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
6971
7072let load_bytes mem a n =
7173 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 =
4747 tab.content < - after
4848
4949let 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
5152
5253let store tab i r =
5354 let TableType (lim, t) = tab.ty in
5455 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
5658
5759let blit tab offset rs =
5860 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 =
156156struct
157157 let make n x =
158158 if n < 0l || Int64. of_int32 n > Int64. of_int max_int then
159- raise ( Invalid_argument " Array32.make" ) ;
159+ invalid_arg " Array32.make" ;
160160 Array. make (Int32. to_int n) x
161161
162162 let length a = Int32. of_int (Array. length a)
@@ -179,7 +179,7 @@ struct
179179 struct
180180 let create kind layout n =
181181 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" ;
183183 Array1. create kind layout (Int64. to_int n)
184184
185185 let dim a = Int64. of_int (Array1. dim a)
@@ -204,7 +204,7 @@ struct
204204 let force o =
205205 match o with
206206 | Some y -> y
207- | None -> raise ( Invalid_argument " Option.force" )
207+ | None -> invalid_arg " Option.force"
208208
209209 let map f = function
210210 | Some x -> Some (f x)
You can’t perform that action at this time.
0 commit comments