diff --git a/automation/tests/aegisub.cpp b/automation/tests/aegisub.cpp index 8592ad87e..197ab0320 100644 --- a/automation/tests/aegisub.cpp +++ b/automation/tests/aegisub.cpp @@ -46,7 +46,12 @@ int main(int argc, char **argv) { // Init lua state lua_State *L = lua_open(); - agi::lua::preload_modules(L); + if (!L) { + fprintf(stderr, "Failed to create Lua state\n"); + return 1; + } + + preload_modules(L); Install(L, {"include"}); // Build arg table for scripts diff --git a/src/auto4_lua.cpp b/src/auto4_lua.cpp index 2d3569963..cf971b859 100644 --- a/src/auto4_lua.cpp +++ b/src/auto4_lua.cpp @@ -401,6 +401,7 @@ namespace { // create lua environment L = lua_open(); + if (!L) return; bool loaded = false; BOOST_SCOPE_EXIT_ALL(&) { if (!loaded) Destroy(); };