From 34cfd9b850097d6a2241053e3e6faf99756d3702 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Sun, 24 Nov 2019 23:12:29 +0100 Subject: [PATCH] core: Throw instead of segfault on non-existing input file. WIP. Reported by theruran. * src/posix.c (open_input_file): Call error instead of failing silently. --- src/posix.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/posix.c b/src/posix.c index 9f190fc6..e2bcba09 100644 --- a/src/posix.c +++ b/src/posix.c @@ -214,7 +214,10 @@ current_input_port () struct scm * open_input_file (struct scm *file_name) { - return make_number (mes_open (cell_bytes (file_name->string), O_RDONLY, 0)); + int filedes = mes_open (cell_bytes (file_name->string), 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); } struct scm *