From 10e86abb44cf9fa4c18ce87e3bcce64b4adcf784 Mon Sep 17 00:00:00 2001 From: alessandrobason <1902881@uad.ac.uk> Date: Thu, 4 Nov 2021 00:10:42 +0000 Subject: [PATCH] filed a bug in fileReadWholeText --- file.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/file.c b/file.c index 3b5b366..82336b6 100644 --- a/file.c +++ b/file.c @@ -92,6 +92,7 @@ uint64_t fileTell(file_t *ctx) { #else #include +#include #include #include @@ -208,6 +209,10 @@ fread_buf_t fileReadWholeFP(file_t *ctx) { str_t fileReadWholeText(const char *fname) { file_t fp = fileOpen(fname, FILE_READ); + if(!fileIsValid(&fp)) { + err("couldn't open file %s -> %d", fname); + return strInit(); + } str_t contents = fileReadWholeFPText(&fp); fileClose(&fp); return contents;