summaryrefslogtreecommitdiff
path: root/src/vector.c
diff options
context:
space:
mode:
authorJacques Germishuys <jacquesg@striata.com>2014-04-06 15:06:46 +0200
committerJacques Germishuys <jacquesg@striata.com>2014-04-06 15:16:44 +0200
commit4998009a28929affb3f22274b1024bc5a8cdbfb6 (patch)
tree4c4fdecd430e1851055c8b8816757abe9db0090e /src/vector.c
parent4c219cf64868d1b3fc2c5df0bbf803b40c6e4cef (diff)
downloadlibgit2-4998009a28929affb3f22274b1024bc5a8cdbfb6.tar.gz
Don't lose our elements when calling git_vector_set()
Diffstat (limited to 'src/vector.c')
-rw-r--r--src/vector.c6
1 files 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];