diff options
| author | Carlos Martín Nieto <cmn@dwim.me> | 2015-02-15 05:13:50 +0100 |
|---|---|---|
| committer | Carlos Martín Nieto <cmn@dwim.me> | 2015-02-15 05:13:50 +0100 |
| commit | a7fa970f8b216b79a5d237a9d87ac88e2371ae46 (patch) | |
| tree | 3edf83ca5682fcca6f6f2bef1e089f89ccc85017 /src/merge.c | |
| parent | b23c206e591260bb184990fea4a8104f7b27b897 (diff) | |
| parent | 0f07d54b44825399e5d13499328135771c8d0b43 (diff) | |
| download | libgit2-a7fa970f8b216b79a5d237a9d87ac88e2371ae46.tar.gz | |
Merge pull request #2895 from ethomson/alloc_overflow
allocations: test for overflow of requested size
Diffstat (limited to 'src/merge.c')
| -rw-r--r-- | src/merge.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/merge.c b/src/merge.c index 7c38b5692..e4b60c847 100644 --- a/src/merge.c +++ b/src/merge.c @@ -1169,7 +1169,7 @@ int git_merge_diff_list__find_renames( goto done; if (diff_list->conflicts.length <= opts->target_limit) { - cache_size = diff_list->conflicts.length * 3; + GITERR_CHECK_ALLOC_MULTIPLY(&cache_size, diff_list->conflicts.length, 3); cache = git__calloc(cache_size, sizeof(void *)); GITERR_CHECK_ALLOC(cache); @@ -2223,12 +2223,13 @@ static int merge_ancestor_head( size_t their_heads_len) { git_oid *oids, ancestor_oid; - size_t i; + size_t i, alloc_len; int error = 0; assert(repo && our_head && their_heads); - oids = git__calloc(their_heads_len + 1, sizeof(git_oid)); + GITERR_CHECK_ALLOC_ADD(&alloc_len, their_heads_len, 1); + oids = git__calloc(alloc_len, sizeof(git_oid)); GITERR_CHECK_ALLOC(oids); git_oid_cpy(&oids[0], git_commit_id(our_head->commit)); |
