From 661ccea88ae56357f175cbcbb893263cf90ab623 Mon Sep 17 00:00:00 2001 From: tsxv478 Date: Fri, 29 Nov 2024 00:01:03 +0300 Subject: last(): exit if file is empty --- note.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/note.c b/note.c index 3cca833..4883be1 100644 --- a/note.c +++ b/note.c @@ -76,7 +76,9 @@ last(char *fullpath) } fseek(fp, 0, SEEK_END); - pos = ftell(fp); + + if (!(pos = ftell(fp))) + exit(0); while (1) { fseek(fp, --pos, SEEK_SET); -- cgit v1.2.3