From 4998009a28929affb3f22274b1024bc5a8cdbfb6 Mon Sep 17 00:00:00 2001 From: Jacques Germishuys Date: Sun, 6 Apr 2014 15:06:46 +0200 Subject: [PATCH] Don't lose our elements when calling git_vector_set() --- src/vector.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/vector.c b/src/vector.c index e5d8919d3..67883cbc5 100644 --- a/src/vector.c +++ b/src/vector.c @@ -327,8 +327,10 @@ int git_vector_resize_to(git_vector *v, size_t new_length) int git_vector_set(void **old, git_vector *v, size_t position, void *value) { - if (git_vector_resize_to(v, position + 1) < 0) - return -1; + if (position + 1 > v->length) { + if (git_vector_resize_to(v, position + 1) < 0) + return -1; + } if (old != NULL) *old = v->contents[position];