From dd58402ef35ef8971920810768b87717c2a2169d Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Thu, 1 Oct 2015 21:37:32 -0400 Subject: [PATCH] Avoid possible NULL dereference I actually think this might be a false positive, but the libgit2 API doesn't appear to guarantee that ancestor is not NULL, so let's add that check. Coverity CID 1325296 Signed-off-by: Dirk Hohndel --- git-access.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-access.c b/git-access.c index d78aa0629..25f1d9e8a 100644 --- a/git-access.c +++ b/git-access.c @@ -329,7 +329,7 @@ static int try_to_git_merge(git_repository *repo, git_reference *local, git_refe // the file was removed on one side or the other - just remove it fprintf(stderr, "looks like a delete on one side; removing the file from the index\n"); error = git_index_remove(merged_index, ours ? ours->path : theirs->path, GIT_INDEX_STAGE_ANY); - } else { + } else if (ancestor) { error = git_index_conflict_remove(merged_index, ours ? ours->path : theirs ? theirs->path : ancestor->path); } if (error) {