#6575: fail early in Array.init when size < 0 to avoid calling the callback in that case. (Cherry-picked from 4.02, rev 15898.)
git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@15899 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02master
parent
4c48d802cb
commit
90a956b47e
2
Changes
2
Changes
|
@ -235,6 +235,8 @@ Standard library:
|
|||
(Jacques Garrigue, report by Mark Shinwell)
|
||||
- PR#6572: Fatal error with recursive modules
|
||||
(Jacques Garrigue, report by Quentin Stievenart)
|
||||
- PR#6575: Array.init evaluates callback although it should not do so
|
||||
(Alain Frisch, report by Gerd Stolpmann)
|
||||
- PR#6578: Recursive module containing alias causes Segmentation fault
|
||||
(Jacques Garrigue)
|
||||
- PR#6581: Some bugs in generative functors
|
||||
|
|
|
@ -29,6 +29,10 @@ external make_float: int -> float array = "caml_make_float_vect"
|
|||
|
||||
let init l f =
|
||||
if l = 0 then [||] else
|
||||
if l < 0 then invalid_arg "Array.init"
|
||||
(* See #6575. We could also check for maximum array size, but this depends
|
||||
on whether we create a float array or a regular one... *)
|
||||
else
|
||||
let res = create l (f 0) in
|
||||
for i = 1 to pred l do
|
||||
unsafe_set res i (f i)
|
||||
|
|
Loading…
Reference in New Issue