diff -u nano/files.c nano-loadhist/files.c --- nano/files.c Tue Feb 11 22:02:43 2003 +++ nano-loadhist/files.c Wed Feb 12 15:08:26 2003 @@ -2891,7 +2891,7 @@ buf = charalloc(1024); while (fgets(buf, 1023, hist) != 0) { ptr = buf; - while (*ptr != '\n') + while (*ptr != '\n' && *ptr != '\0' && ptr < buf + 1023) ptr++; *ptr = '\0'; if (strlen(buf))