1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-24 07:40:52 +00:00

tail -F: fix crash

When show() detects an error and closes the file and follow() wants to
close it again, a NULL dereference occurs.

PR:	280910
MFC after:	1 week
This commit is contained in:
Andre Albsmeier 2024-08-19 10:54:24 +03:00 committed by Konstantin Belousov
parent 8132e95909
commit 308399a179

View File

@ -379,7 +379,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));