diff options
author | sanine <sanine.not@pm.me> | 2023-03-13 12:29:18 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2023-03-13 12:29:18 -0500 |
commit | 184a9517a619c0052aabd8ad6ab00ed0d2607e97 (patch) | |
tree | ae0bbc82be387255215e5f1cdc85fe5a2ca1fdff /src/import | |
parent | cc7dfef17ffaa41a675364fb5f0561a13d6b0dba (diff) |
fix null pointer errors
Diffstat (limited to 'src/import')
-rw-r--r-- | src/import/import.c | 4 |
1 files changed, 4 insertions, 0 deletions
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); |