From 46b73f494bb6517057082c7a2c95470e5a6f67c0 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. 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 7ba2e991..fd753232 100644 --- a/src/posix.c +++ b/src/posix.c @@ -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