core: Throw instead of segfault on non-existing input file.

Reported by theruran.

* src/posix.c (open_input_file): Call error instead of failing silently.
This commit is contained in:
Jan Nieuwenhuizen 2019-11-24 23:12:29 +01:00
parent 204dcaa452
commit 46b73f494b
No known key found for this signature in database
GPG key ID: F3C1A0D9C1D65273

View file

@ -188,7 +188,10 @@ current_input_port ()
SCM
open_input_file (SCM file_name)
{
return MAKE_NUMBER (mes_open (CSTRING (file_name), O_RDONLY, 0));
int filedes = mes_open (CSTRING (file_name), O_RDONLY, 0);
if (filedes == -1)
error (cell_symbol_system_error, cons (MAKE_STRING0 ("No such file or directory"), file_name));
return MAKE_NUMBER (filedes);
}
SCM