do not segfault on empty input

This commit is contained in:
anon 2024-03-01 19:36:23 +01:00
parent 3bc43448fc
commit e332f72d22

View File

@ -114,11 +114,15 @@ static void callback_handler(char *line) {
char ch;
shellpath(filename, sizeof(filename), line);
file = fopen(filename, "a+");
seekpage(0);
while ((ch = getc(refsfound)) != EOF) {
putc(ch, file);
if (file) {
seekpage(0);
while ((ch = getc(refsfound)) != EOF) {
putc(ch, file);
}
fclose(file);
} else {
postmsg2("Failed to open file.");
}
fclose(file);
input_mode = INPUT_NORMAL;
} return;
case INPUT_READ: {