summaryrefslogtreecommitdiff
path: root/src/import
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2023-03-13 12:29:18 -0500
committersanine <sanine.not@pm.me>2023-03-13 12:29:18 -0500
commit184a9517a619c0052aabd8ad6ab00ed0d2607e97 (patch)
treeae0bbc82be387255215e5f1cdc85fe5a2ca1fdff /src/import
parentcc7dfef17ffaa41a675364fb5f0561a13d6b0dba (diff)
fix null pointer errors
Diffstat (limited to 'src/import')
-rw-r--r--src/import/import.c4
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);