Commit 7808c937 by Patrick Steinhardt

index: plug memory leak in `read_conflict_names`

parent 003c5e46
......@@ -2193,9 +2193,10 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
#define read_conflict_name(ptr) \
len = p_strnlen(buffer, size) + 1; \
if (size < len) \
return index_error_invalid("reading conflict name entries"); \
\
if (size < len) { \
index_error_invalid("reading conflict name entries"); \
goto out_err; \
} \
if (len == 1) \
ptr = NULL; \
else { \
......@@ -2216,6 +2217,15 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
read_conflict_name(conflict_name->theirs);
if (git_vector_insert(&index->names, conflict_name) < 0)
goto out_err;
continue;
out_err:
git__free(conflict_name->ancestor);
git__free(conflict_name->ours);
git__free(conflict_name->theirs);
git__free(conflict_name);
return -1;
}
......
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