Skip to content

Commit 756138e

Browse files
committed
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`.
1 parent a76d750 commit 756138e

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/blame_git.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -517,11 +517,12 @@ static int pass_blame(git_blame *blame, git_blame__origin *origin, uint32_t opt)
517517
if (!num_parents) {
518518
git_oid_cpy(&blame->options.oldest_commit, git_commit_id(commit));
519519
goto finish;
520-
}
521-
else if (num_parents < (int)ARRAY_SIZE(sg_buf))
520+
} else if (num_parents < (int)ARRAY_SIZE(sg_buf))
522521
memset(sg_buf, 0, sizeof(sg_buf));
523-
else
522+
else {
524523
sg_origin = git__calloc(num_parents, sizeof(*sg_origin));
524+
GITERR_CHECK_ALLOC(sg_origin);
525+
}
525526

526527
for (i=0; i<num_parents; i++) {
527528
git_commit *p;

0 commit comments

Comments
 (0)