diff options
author | Patrick Steinhardt <ps@pks.im> | 2016-02-22 14:01:50 +0100 |
---|---|---|
committer | Patrick Steinhardt <ps@pks.im> | 2016-02-23 11:50:23 +0100 |
commit | be8479c9873315afcf6b86f0b1bb79052a23b363 (patch) | |
tree | 320a0241fad1398ffca365e7cccf031de77fc552 | |
parent | bac52ab0f2e8d09de1f98590f177e9e847cdb11b (diff) | |
download | libgit2-be8479c9873315afcf6b86f0b1bb79052a23b363.tar.gz |
diff_print: assert patch is non-NULL
When invoking `diff_print_info_init_frompatch` it is obvious that
the patch should be non-NULL. We explicitly check if the variable
is set and continue afterwards, happily dereferencing the
potential NULL-pointer.
Fix this by instead asserting that patch is set. This also
silences Coverity.
-rw-r--r-- | src/diff_print.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/diff_print.c b/src/diff_print.c index bc2d6fab0..dae9e341d 100644 --- a/src/diff_print.c +++ b/src/diff_print.c @@ -92,7 +92,11 @@ static int diff_print_info_init_frompatch( git_diff_line_cb cb, void *payload) { - git_repository *repo = patch && patch->diff ? patch->diff->repo : NULL; + git_repository *repo; + + assert(patch); + + repo = patch->diff ? patch->diff->repo : NULL; memset(pi, 0, sizeof(diff_print_info)); |