Merge pull request #65 from bbbradsmith/lua_stack_fix

extra stack clear for lua library table registration
This commit is contained in:
CaH4e3 2019-06-29 00:12:01 +03:00 committed by GitHub
commit 5b425c72f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -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);