Commit 4acef5eedd5863726d7d94dde5b8e8beb13aeaf2

Stefan Sperling 2018-12-24T22:26:29

fix crash in tog when diffing a root commit

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
diff --git a/tog/tog.c b/tog/tog.c
index e6c12b6..b070363 100644
--- a/tog/tog.c
+++ b/tog/tog.c
@@ -1228,13 +1228,13 @@ open_diff_view_for_commit(struct tog_view **new_view, int begin_x,
 	struct got_object_qid *parent_id;
 	struct tog_view *diff_view;
 
-	parent_id = SIMPLEQ_FIRST(got_object_commit_get_parent_ids(commit));
-
 	diff_view = view_open(0, 0, 0, begin_x, TOG_VIEW_DIFF);
 	if (diff_view == NULL)
 		return got_error_from_errno();
 
-	err = open_diff_view(diff_view, parent_id->id, commit_id, repo);
+	parent_id = SIMPLEQ_FIRST(got_object_commit_get_parent_ids(commit));
+	err = open_diff_view(diff_view, parent_id ? parent_id->id : NULL,
+	    commit_id, repo);
 	if (err == NULL)
 		*new_view = diff_view;
 	return err;