From 408c14fac7076678bad0239915b109aaa666d75b Mon Sep 17 00:00:00 2001 From: Yotam Barnoy Date: Mon, 21 Feb 2022 18:50:19 +0200 Subject: [PATCH] CCVector.insert: check if there's a need to blit Co-authored-by: Simon Cruanes --- src/core/CCVector.ml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/core/CCVector.ml b/src/core/CCVector.ml index 40e6198a..29f9a01c 100644 --- a/src/core/CCVector.ml +++ b/src/core/CCVector.ml @@ -351,7 +351,7 @@ let insert v i x = if v.size = Array.length v.vec then grow_with_ v ~filler:x; (* Shift the following elements, then put the element at i *) - Array.blit v.vec i v.vec (i+1) (v.size - i); + if i < v.size then Array.blit v.vec i v.vec (i+1) (v.size - i); v.vec.(i) <- x; v.size <- v.size + 1