Skip to content

Commit

Permalink
Merge pull request TASEmulators#65 from bbbradsmith/lua_stack_fix
Browse files Browse the repository at this point in the history
extra stack clear for lua library table registration
  • Loading branch information
g0me3 authored Jun 28, 2019
2 parents 705f1c9 + 17e36e9 commit 5b425c7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/lua-engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 5b425c7

Please sign in to comment.