mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-14 04:15:40 +00:00
index: plug memory leak in read_conflict_names
This commit is contained in:
parent
003c5e46a8
commit
7808c93797
18
src/index.c
18
src/index.c
@ -2193,9 +2193,10 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
|
|||||||
|
|
||||||
#define read_conflict_name(ptr) \
|
#define read_conflict_name(ptr) \
|
||||||
len = p_strnlen(buffer, size) + 1; \
|
len = p_strnlen(buffer, size) + 1; \
|
||||||
if (size < len) \
|
if (size < len) { \
|
||||||
return index_error_invalid("reading conflict name entries"); \
|
index_error_invalid("reading conflict name entries"); \
|
||||||
\
|
goto out_err; \
|
||||||
|
} \
|
||||||
if (len == 1) \
|
if (len == 1) \
|
||||||
ptr = NULL; \
|
ptr = NULL; \
|
||||||
else { \
|
else { \
|
||||||
@ -2216,7 +2217,16 @@ static int read_conflict_names(git_index *index, const char *buffer, size_t size
|
|||||||
read_conflict_name(conflict_name->theirs);
|
read_conflict_name(conflict_name->theirs);
|
||||||
|
|
||||||
if (git_vector_insert(&index->names, conflict_name) < 0)
|
if (git_vector_insert(&index->names, conflict_name) < 0)
|
||||||
return -1;
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
#undef read_conflict_name
|
#undef read_conflict_name
|
||||||
|
Loading…
Reference in New Issue
Block a user