summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2017-03-28 09:15:53 +0200
committerPatrick Steinhardt <ps@pks.im>2017-04-04 11:58:46 +0200
commit756138e4755c93265e34704ee95874c0d81425e5 (patch)
tree0bb16b850dabb2f70ae4907956bd1eb658f66a7c
parenta76d75021c50315ab52d7a4e60419dc2e64c47e9 (diff)
downloadlibgit2-756138e4755c93265e34704ee95874c0d81425e5.tar.gz
blame_git: check return value of `git__calloc`
We do not check the return value of `git__calloc`, which may return `NULL` in out-of-memory situations. Fix the error by using `GITERR_CHECK_ALLOC`.
-rw-r--r--src/blame_git.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/blame_git.c b/src/blame_git.c
index 6d2f1531f..13f5cb47c 100644
--- a/src/blame_git.c
+++ b/src/blame_git.c
@@ -517,11 +517,12 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
if (!num_parents) {
git_oid_cpy(&blame->options.oldest_commit, git_commit_id(commit));
goto finish;
- }
- else if (num_parents < (int)ARRAY_SIZE(sg_buf))
+ } else if (num_parents < (int)ARRAY_SIZE(sg_buf))
memset(sg_buf, 0, sizeof(sg_buf));
- else
+ else {
sg_origin = git__calloc(num_parents, sizeof(*sg_origin));
+ GITERR_CHECK_ALLOC(sg_origin);
+ }
for (i=0; i<num_parents; i++) {
git_commit *p;