Add a check for the invalid status of `0` for `diff_filepair` when certain object files are missing. When these object files are missing, 'git log' returns 'fatal: bad object HEAD' but 'git diff' segfaults. Normally, the `diff_filepair` status should be a character, but when object files are removed, status becomes a zero character which isn't listed as one of the possible status letters in `Documentation/diff-format.txt`. This patch checks for that invalid status character and gracefully exits with an error message. Signed-off-by: Jake Roggenbuck <jakeroggenbuck2@xxxxxxxxx> --- diff.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/diff.c b/diff.c index 6c96154fed..aeab1ac445 100644 --- a/diff.c +++ b/diff.c @@ -7018,6 +7018,10 @@ void diff_queued_diff_prefetch(void *repository) for (i = 0; i < q->nr; i++) { struct diff_filepair *p = q->queue[i]; + + if (!p->status) + die("invalid diff status"); + diff_add_if_missing(repo, &to_fetch, p->one); diff_add_if_missing(repo, &to_fetch, p->two); } -- 2.47.0