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 <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-10-01 21:37:32 -04:00
parent a51903fbb6
commit dd58402ef3

View file

@ -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) {