Commit Diff


commit - d23ace9754f9a3cb832708f7cdf5eb08a7f4573a
commit + 3aac7cf700bfd5d57ab11824e1e6f3f646101bd7
blob - 2057dbe7cb12613928efd1ba604f242836538377
blob + 1ea84c54566b8c259418678d43d0bf728fc503d5
--- got/got.c
+++ got/got.c
@@ -4816,6 +4816,10 @@ cmd_histedit(int argc, char *argv[])
 			goto done;
 		parent_ids = got_object_commit_get_parent_ids(commit);
 		pid = SIMPLEQ_FIRST(parent_ids);
+		if (pid == NULL) {
+			error = got_error(GOT_ERR_EMPTY_HISTEDIT);
+			goto done;
+		}
 		error = collect_commits_to_rebase(&commits, head_commit_id,
 		    pid->id, base_commit_id,
 		    got_worktree_get_path_prefix(worktree), repo);
@@ -4844,6 +4848,10 @@ cmd_histedit(int argc, char *argv[])
 			goto done;
 		parent_ids = got_object_commit_get_parent_ids(commit);
 		pid = SIMPLEQ_FIRST(parent_ids);
+		if (pid == NULL) {
+			error = got_error(GOT_ERR_EMPTY_HISTEDIT);
+			goto done;
+		}
 		error = collect_commits_to_rebase(&commits, head_commit_id,
 		    pid->id, got_worktree_get_base_commit_id(worktree),
 		    got_worktree_get_path_prefix(worktree), repo);