summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2016-02-22 14:01:50 +0100
committerPatrick Steinhardt <ps@pks.im>2016-02-23 11:50:23 +0100
commitbe8479c9873315afcf6b86f0b1bb79052a23b363 (patch)
tree320a0241fad1398ffca365e7cccf031de77fc552
parentbac52ab0f2e8d09de1f98590f177e9e847cdb11b (diff)
downloadlibgit2-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.c6
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));