Merge branch 'ao/diff-populate-filespec-lstat-errorpath-fix'

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()
This commit is contained in:
Junio C Hamano
2017-11-09 14:31:26 +09:00

2
diff.c
View File

@ -3545,7 +3545,6 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
int fd; int fd;
if (lstat(s->path, &st) < 0) { if (lstat(s->path, &st) < 0) {
if (errno == ENOENT) {
err_empty: err_empty:
err = -1; err = -1;
empty: empty:
@ -3553,7 +3552,6 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags)
s->size = 0; s->size = 0;
return err; return err;
} }
}
s->size = xsize_t(st.st_size); s->size = xsize_t(st.st_size);
if (!s->size) if (!s->size)
goto empty; goto empty;