Merge pull request #2250 from jacquesg/vector-leak

Don't lose our elements when calling git_vector_set()
This commit is contained in:
Vicent Marti 2014-04-06 16:22:29 +02:00
commit 52056db9c1

View File

@ -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];