Commit 5c3e01d89172cd5f3bad6bbf7151556f44ac2dba

Jacques Germishuys 2015-01-25T14:40:23

Ensure the diff hunk callback is specified before trying to dereference it

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/diff_patch.c b/src/diff_patch.c
index 317dbea..7cdf6f3 100644
--- a/src/diff_patch.c
+++ b/src/diff_patch.c
@@ -822,7 +822,8 @@ int git_patch__invoke_callbacks(
 	for (i = 0; !error && i < git_array_size(patch->hunks); ++i) {
 		diff_patch_hunk *h = git_array_get(patch->hunks, i);
 
-		error = hunk_cb(patch->delta, &h->hunk, payload);
+		if (hunk_cb)
+			error = hunk_cb(patch->delta, &h->hunk, payload);
 
 		if (!line_cb)
 			continue;