do not segfault on empty input

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

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