TECO-64 icon indicating copy to clipboard operation
TECO-64 copied to clipboard

`^N` (end of file flag) cause crashes when no input file.

Open LdBeth opened this issue 3 months ago • 0 comments

And a fix is provided:

diff --git a/src/flag_cmd.c b/src/flag_cmd.c
index e73646a2..9ede57df 100644
--- a/src/flag_cmd.c
+++ b/src/flag_cmd.c
@@ -514,9 +514,13 @@ bool scan_flag1(struct cmd *cmd)
             confirm(cmd, NO_N);
 
             struct ifile *ifile = &ifiles[istream];
-            int_t eof = feof(ifile->fp) ? -1 : 0;
+            if (ifile->fp == NULL)
+              store_val(0);
+            else {
+              int_t eof = feof(ifile->fp) ? -1 : 0;
 
-            store_val(eof);
+              store_val(eof);
+            }
 
             return true;
         }

LdBeth avatar Mar 15 '24 03:03 LdBeth