From: Junio C Hamano Date: Wed, 15 Nov 2017 03:04:59 +0000 (+0900) Subject: Merge branch 'ao/diff-populate-filespec-lstat-errorpath-fix' into maint X-Git-Tag: v2.15.1~28 X-Git-Url: https://www.git.lorimer.id.au/gitweb.git/diff_plain/eae59c1b574d2a424abc2447985d10c06f2a840e?hp=4a1ddb561cad07277be60a6e04513da5eb9db582 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() --- diff --git a/diff.c b/diff.c index e6814b9e9c..1898dd307d 100644 --- a/diff.c +++ b/diff.c @@ -3545,14 +3545,12 @@ int diff_populate_filespec(struct diff_filespec *s, unsigned int flags) int fd; if (lstat(s->path, &st) < 0) { - if (errno == ENOENT) { - err_empty: - err = -1; - empty: - s->data = (char *)""; - s->size = 0; - return err; - } + err_empty: + err = -1; + empty: + s->data = (char *)""; + s->size = 0; + return err; } s->size = xsize_t(st.st_size); if (!s->size)