← Back to team overview

widelands-dev team mailing list archive

[Merge] lp:~widelands-dev/widelands/luatable-stack-fix into lp:widelands

 

Miroslav Remák has proposed merging lp:~widelands-dev/widelands/luatable-stack-fix into lp:widelands.

Requested reviews:
  Widelands Developers (widelands-dev)

For more details, see:
https://code.launchpad.net/~widelands-dev/widelands/luatable-stack-fix/+merge/290650

This should fix the bug found in lp:~widelands-dev/widelands/lua-driven-help. Enabling Lua asserts showed stack overflow. Apparently, the stack size is limited to 20 items by default, but can be increased with the lua_checkstack function - we probably don't need to do that, though. The overflow is caused by LuaTable::has_key calls clogging up the stack.
-- 
Your team Widelands Developers is requested to review the proposed merge of lp:~widelands-dev/widelands/luatable-stack-fix into lp:widelands.
=== modified file 'src/scripting/lua_table.h'
--- src/scripting/lua_table.h	2015-03-01 09:21:20 +0000
+++ src/scripting/lua_table.h	2016-03-31 19:38:23 +0000
@@ -93,6 +93,7 @@
 	template <typename KeyType> bool has_key(const KeyType& key) const {
 		try {
 			get_existing_table_value(key);
+			lua_pop(L_, 1);
 			return true;
 		}
 		catch (LuaTableKeyError&) {


Follow ups