Skip to content

Commit eae59c1

Browse files
committed
Merge branch 'ao/diff-populate-filespec-lstat-errorpath-fix' into maint
After an error from lstat(), diff_populate_filespec() function sometimes still went ahead and used invalid data in struct stat, which has been fixed. * ao/diff-populate-filespec-lstat-errorpath-fix: diff: fix lstat() error handling in diff_populate_filespec()
2 parents 4a1ddb5 + 10e0ca8 commit eae59c1

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

diff.c

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3545,14 +3545,12 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
35453545
int fd;
35463546

35473547
if (lstat(s->path, &st) < 0) {
3548-
if (errno == ENOENT) {
3549-
err_empty:
3550-
err = -1;
3551-
empty:
3552-
s->data = (char *)"";
3553-
s->size = 0;
3554-
return err;
3555-
}
3548+
err_empty:
3549+
err = -1;
3550+
empty:
3551+
s->data = (char *)"";
3552+
s->size = 0;
3553+
return err;
35563554
}
35573555
s->size = xsize_t(st.st_size);
35583556
if (!s->size)

0 commit comments

Comments
 (0)