summaryrefslogtreecommitdiff
path: root/src/diff_tform.c
diff options
context:
space:
mode:
authorCarlos Martín Nieto <cmn@dwim.me>2015-02-15 05:13:50 +0100
committerCarlos Martín Nieto <cmn@dwim.me>2015-02-15 05:13:50 +0100
commita7fa970f8b216b79a5d237a9d87ac88e2371ae46 (patch)
tree3edf83ca5682fcca6f6f2bef1e089f89ccc85017 /src/diff_tform.c
parentb23c206e591260bb184990fea4a8104f7b27b897 (diff)
parent0f07d54b44825399e5d13499328135771c8d0b43 (diff)
downloadlibgit2-a7fa970f8b216b79a5d237a9d87ac88e2371ae46.tar.gz
Merge pull request #2895 from ethomson/alloc_overflow
allocations: test for overflow of requested size
Diffstat (limited to 'src/diff_tform.c')
-rw-r--r--src/diff_tform.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/diff_tform.c b/src/diff_tform.c
index 9133a9b14..8ee568cf4 100644
--- a/src/diff_tform.c
+++ b/src/diff_tform.c
@@ -811,6 +811,7 @@ int git_diff_find_similar(
size_t num_deltas, num_srcs = 0, num_tgts = 0;
size_t tried_srcs = 0, tried_tgts = 0;
size_t num_rewrites = 0, num_updates = 0, num_bumped = 0;
+ size_t sigcache_size;
void **sigcache = NULL; /* cache of similarity metric file signatures */
diff_find_match *tgt2src = NULL;
diff_find_match *src2tgt = NULL;
@@ -831,7 +832,8 @@ int git_diff_find_similar(
if ((opts.flags & GIT_DIFF_FIND_ALL) == 0)
goto cleanup;
- sigcache = git__calloc(num_deltas * 2, sizeof(void *));
+ GITERR_CHECK_ALLOC_MULTIPLY(&sigcache_size, num_deltas, 2);
+ sigcache = git__calloc(sigcache_size, sizeof(void *));
GITERR_CHECK_ALLOC(sigcache);
/* Label rename sources and targets