From b7370a6d461a02eb9c1b75c56047450577ce2394 Mon Sep 17 00:00:00 2001 From: Glenn Strauss Date: Fri, 9 Oct 2020 09:34:15 -0400 Subject: [PATCH] [core] save errno around close() if fstat() fails (should not happen, since file was just opened) --- src/stat_cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/stat_cache.c b/src/stat_cache.c index 8729d7bc..61f1cb1f 100644 --- a/src/stat_cache.c +++ b/src/stat_cache.c @@ -1101,7 +1101,9 @@ int stat_cache_open_rdonly_fstat (const buffer *name, struct stat *st, int symli if (0 == fstat(fd, st)) { return fd; } else { + const int errnum = errno; close(fd); + errno = errnum; } } return -1;