Skip to content

Commit dc7090e

Browse files
Junio C HamanoLinus Torvalds
authored andcommitted
[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 <junkio@cox.net> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
1 parent 206de27 commit dc7090e

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

diff.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ static void run_diff(const char *name,
555555
{
556556
const char *pgm = external_diff();
557557
if (!pgm &&
558+
one && two &&
558559
DIFF_FILE_VALID(one) && DIFF_FILE_VALID(two) &&
559560
(S_IFMT & one->mode) != (S_IFMT & two->mode)) {
560561
/* a filepair that changes between file and symlink

diffcore.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ struct diff_filespec {
3333
* if false, use the name and read from
3434
* the filesystem.
3535
*/
36-
#define DIFF_FILE_VALID(spec) ((spec) && ((spec)->mode) != 0)
36+
#define DIFF_FILE_VALID(spec) (((spec)->mode) != 0)
3737
unsigned should_free : 1; /* data should be free()'ed */
3838
unsigned should_munmap : 1; /* data should be munmap()'ed */
3939
};

0 commit comments

Comments
 (0)