From 88cbb81ec44ae0688d7e0b570e906b23b50d3c9e Mon Sep 17 00:00:00 2001 From: mniip Date: Sat, 4 May 2013 04:11:52 +0400 Subject: [PATCH] fix crash on non-string error in step and other functions --- src/cat/LegacyLuaAPI.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/cat/LegacyLuaAPI.cpp b/src/cat/LegacyLuaAPI.cpp index 2166b1411..4d3c0c84a 100644 --- a/src/cat/LegacyLuaAPI.cpp +++ b/src/cat/LegacyLuaAPI.cpp @@ -514,7 +514,7 @@ int luacon_keyevent(int key, int modifier, int event) callret = lua_pcall(l, 4, 1, 0); if (callret) { - if (!strcmp(luaL_optstring(l, -1, ""), "Error: Script not responding")) + if (!strcmp(luacon_geterror(), "Error: Script not responding")) { ui::Engine::Ref().LastTick(clock()); for(j=i;j<=c-1;j++) @@ -566,7 +566,7 @@ int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel) callret = lua_pcall(l, 5, 1, 0); if (callret) { - if (!strcmp(luaL_optstring(l, -1, ""), "Error: Script not responding")) + if (!strcmp(luacon_geterror(), "Error: Script not responding")) { ui::Engine::Ref().LastTick(clock()); for(j=i;j<=c-1;j++) @@ -579,7 +579,7 @@ int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel) c--; i--; } - luacon_ci->Log(CommandInterface::LogError, luaL_optstring(l, -1, "")); + luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); lua_pop(l, 1); } else @@ -627,7 +627,7 @@ int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::s callret = lua_pcall(l, 0, 0, 0); if (callret) { - if (!strcmp(luaL_optstring(l, -1, ""), "Error: Script not responding")) + if (!strcmp(luacon_geterror(), "Error: Script not responding")) { ui::Engine::Ref().LastTick(clock()); for(j=i;j<=c-1;j++) @@ -640,7 +640,7 @@ int luacon_step(int mx, int my, std::string selectl, std::string selectr, std::s c--; i--; } - luacon_ci->Log(CommandInterface::LogError, luaL_optstring(l, -1, "")); + luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); lua_pop(l, 1); } } @@ -796,7 +796,7 @@ int luacon_graphicsReplacement(GRAPHICS_FUNC_ARGS, int i) callret = lua_pcall(luacon_ci->l, 4, 10, 0); if (callret) { - luacon_ci->Log(CommandInterface::LogError, luaL_optstring(luacon_ci->l, -1, "")); + luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); lua_pop(luacon_ci->l, 1); } else