From 184a9517a619c0052aabd8ad6ab00ed0d2607e97 Mon Sep 17 00:00:00 2001 From: sanine Date: Mon, 13 Mar 2023 12:29:18 -0500 Subject: fix null pointer errors --- src/import/import.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'src/import') diff --git a/src/import/import.c b/src/import/import.c index e2fc250..66bd541 100644 --- a/src/import/import.c +++ b/src/import/import.c @@ -9,7 +9,11 @@ void read_file(void *ctx, const char *filename, int is_mtl, const char *obj_filename, char **buf, size_t *len) { + lua_State *L = ctx; FILE *f = fopen(filename, "rb"); + if (f == NULL) { + luaL_error(L, "failed to open file \"%s\"", filename); + } fseek(f, 0, SEEK_END); *len = ftell(f); fseek(f, 0, SEEK_SET); -- cgit v1.2.1