From 26c0a7962e97bfc281decb3da7efa658254f2bca Mon Sep 17 00:00:00 2001 From: Benno Schulenberg Date: Tue, 28 Sep 2021 09:31:52 +0200 Subject: [PATCH] files: check for a fifo only when it is an existing file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To avoid referencing an uninitialized value. Reported-by: André Kugland https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00031.html --- src/files.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/files.c b/src/files.c index a0ccfbc8..9cae4f85 100644 --- a/src/files.c +++ b/src/files.c @@ -1954,7 +1954,7 @@ bool write_file(const char *name, FILE *thefile, bool tmp, unlink(tempname); } - if (!S_ISFIFO(st.st_mode)) + if (!is_existing_file || !S_ISFIFO(st.st_mode)) #endif /* Ensure the data has reached the disk before reporting it as written. */ if (fflush(thefile) != 0 || fsync(fileno(thefile)) != 0) {