files: check for a fifo only when it is an existing file

To avoid referencing an uninitialized value.

Reported-by: André Kugland <kugland@gmail.com>
  https://lists.gnu.org/archive/html/nano-devel/2021-09/msg00031.html
master
Benno Schulenberg 2021-09-28 09:31:52 +02:00
parent a2b20a1915
commit 26c0a7962e
1 changed files with 1 additions and 1 deletions

View File

@ -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) {