From: Junio C Hamano Date: Mon, 13 Jun 2005 00:23:15 +0000 (-0700) Subject: [PATCH] Re-Fix SIGSEGV on unmerged files in git-diff-files -p X-Git-Tag: v0.99~292 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=dc7090efbc8280e482a6b2dc7419e525cbc3c5d7;p=git.git [PATCH] Re-Fix SIGSEGV on unmerged files in git-diff-files -p When an unmerged path was fed via diff_unmerged() into diffcore, it eventually called run_diff() with "one" and "two" parameters with NULL, but run_diff() was not written carefully enough to notice this situation. Signed-off-by: Junio C Hamano Signed-off-by: Linus Torvalds --- diff --git a/diff.c b/diff.c index 046d9a39..dd1c0b6d 100644 --- a/diff.c +++ b/diff.c @@ -555,6 +555,7 @@ static void run_diff(const char *name, { const char *pgm = external_diff(); if (!pgm && + one && two && DIFF_FILE_VALID(one) && DIFF_FILE_VALID(two) && (S_IFMT & one->mode) != (S_IFMT & two->mode)) { /* a filepair that changes between file and symlink diff --git a/diffcore.h b/diffcore.h index ac159d71..f1b5ca74 100644 --- a/diffcore.h +++ b/diffcore.h @@ -33,7 +33,7 @@ struct diff_filespec { * if false, use the name and read from * the filesystem. */ -#define DIFF_FILE_VALID(spec) ((spec) && ((spec)->mode) != 0) +#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0) unsigned should_free : 1; /* data should be free()'ed */ unsigned should_munmap : 1; /* data should be munmap()'ed */ };