diff options
author | Patrick Steinhardt <ps@pks.im> | 2016-02-22 15:59:15 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2016-02-23 11:50:23 +0100 |
commit | 7808c93797b3fa9f552bd2e24672089b8d27ad2a (patch) | |
tree | 0cd4244a285201bb93b2ad3e287945dd4201241d | |
parent | 003c5e46a84ec7ecee134b9471e6c84ba673847d (diff) | |
download | libgit2-7808c93797b3fa9f552bd2e24672089b8d27ad2a.tar.gz |
index: plug memory leak in `read_conflict_names`
-rw-r--r-- | src/index.c | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/index.c b/src/index.c index d0a0da2c5..85c2f8ea8 100644 --- a/src/index.c +++ b/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) \ 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,7 +2217,16 @@ 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) - 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 |