From 3e21e0bda395a3d948bff04159d31d798766da18 Mon Sep 17 00:00:00 2001 From: nakst <> Date: Sat, 19 Mar 2022 15:29:24 +0000 Subject: [PATCH] scripting engine: better error handling in FileLoad --- util/script.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/util/script.c b/util/script.c index 468d4d8..339980d 100644 --- a/util/script.c +++ b/util/script.c @@ -7882,6 +7882,9 @@ void *LibraryGetAddress(void *library, const char *name) { void *FileLoad(const char *path, size_t *length) { FILE *file = fopen(path, "rb"); if (!file) return NULL; + struct stat s; + fstat(fileno(file), &s); + if (!S_ISREG(s.st_mode)) { fclose(file); errno = EISDIR; return NULL; } fseek(file, 0, SEEK_END); size_t fileSize = ftell(file); fseek(file, 0, SEEK_SET);