From d512c37344eae237390c858e8ccff8c80bca5007 Mon Sep 17 00:00:00 2001 From: Damien Doligez Date: Thu, 16 Mar 2000 16:43:43 +0000 Subject: [PATCH] fix Array.sort (PR#33) git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@2965 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02 --- stdlib/sort.ml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib/sort.ml b/stdlib/sort.ml index 84ea324cb..acde35527 100644 --- a/stdlib/sort.ml +++ b/stdlib/sort.ml @@ -63,6 +63,9 @@ let array cmp arr = end; let pivot = unsafe_get arr mid in let i = ref (lo + 1) and j = ref (hi - 1) in + if not (cmp pivot (unsafe_get arr hi)) + || not (cmp (unsafe_get arr lo) pivot) + then raise (Invalid_argument "Sort.array"); while !i < !j do while not (cmp pivot (unsafe_get arr !i)) do incr i done; while not (cmp (unsafe_get arr !j) pivot) do decr j done;