From 86cc1df32d616c074b793efdc8dfbf851cb5f70b Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sat, 22 Jun 2019 23:52:34 +0200 Subject: HDB: Fix crash when executing Lua with debug options --- engines/hdb/lua-script.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/engines/hdb/lua-script.cpp b/engines/hdb/lua-script.cpp index 9691763afa..edd47bc2e5 100644 --- a/engines/hdb/lua-script.cpp +++ b/engines/hdb/lua-script.cpp @@ -860,12 +860,12 @@ bool LuaScript::initScript(Common::SeekableReadStream *stream, const char *scrip return false; } + lua_getglobal(_state, "level_init"); + // Error handling function to be executed after the function is put on the stack lua_rawgeti(_state, LUA_REGISTRYINDEX, _pcallErrorhandlerRegistryIndex); lua_insert(_state, -2); - lua_getglobal(_state, "level_init"); - if (lua_pcall(_state, 0, 0, -2)) { error("An error occured while executing \"%s\": %s.", "level_init", lua_tostring(_state, -1)); lua_pop(_state, -1); -- cgit v1.2.3