Commit 52056db9 by Vicent Marti

Merge pull request #2250 from jacquesg/vector-leak

Don't lose our elements when calling git_vector_set()
parents 923c8400 4998009a
...@@ -327,8 +327,10 @@ int git_vector_resize_to(git_vector *v, size_t new_length) ...@@ -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) int git_vector_set(void **old, git_vector *v, size_t position, void *value)
{ {
if (git_vector_resize_to(v, position + 1) < 0) if (position + 1 > v->length) {
return -1; if (git_vector_resize_to(v, position + 1) < 0)
return -1;
}
if (old != NULL) if (old != NULL)
*old = v->contents[position]; *old = v->contents[position];
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment