From 17e36e9882aef21a489147c56c74f935fa7c2772 Mon Sep 17 00:00:00 2001 From: bbbradsmith Date: Thu, 27 Jun 2019 03:14:12 -0400 Subject: [PATCH] lua library table registration needs an extra stack clear (is overflowing) --- src/lua-engine.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lua-engine.cpp b/src/lua-engine.cpp index 424c9669..abb16779 100644 --- a/src/lua-engine.cpp +++ b/src/lua-engine.cpp @@ -6098,6 +6098,7 @@ int FCEU_LoadLuaCode(const char *filename, const char *arg) { luaL_register(L, "joypad", joypadlib); luaL_register(L, "zapper", zapperlib); luaL_register(L, "input", inputlib); + lua_settop(L, 0); // clean the stack, because each call to luaL_register leaves a table on top (eventually overflows) luaL_register(L, "savestate", savestatelib); luaL_register(L, "movie", movielib); luaL_register(L, "gui", guilib); @@ -6106,7 +6107,7 @@ int FCEU_LoadLuaCode(const char *filename, const char *arg) { luaL_register(L, "cdlog", cdloglib); luaL_register(L, "taseditor", taseditorlib); luaL_register(L, "bit", bit_funcs); // LuaBitOp library - lua_settop(L, 0); // clean the stack, because each call to luaL_register leaves a table on top + lua_settop(L, 0); // register a few utility functions outside of libraries (in the global namespace) lua_register(L, "print", print);