aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Albsmeier <mail@fbsd2.e4m.org>2024-08-19 07:54:24 +0000
committerKonstantin Belousov <kib@FreeBSD.org>2024-08-21 10:32:49 +0000
commitcf4a34bbc7dfee43e9983a847ecf0fa0ed1d258d (patch)
tree38ba1e61e767cb79ce4e93f0c85ef46033971e66
parent2a1e8d7c30c90e17fccaeec89e4963a8d825063d (diff)
tail -F: fix crash
PR: 280910 (cherry picked from commit 308399a179a49b7b858c725de10177fdb0502fd2)
-rw-r--r--usr.bin/tail/forward.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/usr.bin/tail/forward.c b/usr.bin/tail/forward.c
index a902e006afed..2edf8730e8b1 100644
--- a/usr.bin/tail/forward.c
+++ b/usr.bin/tail/forward.c
@@ -382,7 +382,8 @@ follow(file_info_t *files, enum STYLE style, off_t off)
sb2.st_dev != file->st.st_dev ||
sb2.st_nlink == 0) {
show(file);
- fclose(file->fp);
+ if (file->fp != NULL)
+ fclose(file->fp);
file->fp = ftmp;
memcpy(&file->st, &sb2,
sizeof(struct stat));