pioneerspacesim/pioneer — pull request #2978 by johnbartholomew (2014-06-28 19:48:29+00:00)
Title: Fix stack leak in LuaRef::Save

Fixes #2977 (possibly... needs checking)

LuaRef::Save leaks its value into the Lua stack, which can lead to a Lua stack overflow during serialisation. This turns on LUA_USE_APICHECK to catch Lua stack overflows more reliably instead of just letting them corrupt the heap which is how this bug was found. It also fixes the stack leak in LuaRef::Save.

It is possible (likely?) that there are stack leaks remaining in other places. It would be good to add LUA_DEBUG_START/LUA_DEBUG_END in more places to check for that.

CC @laarmen (maybe you could check other parts of LuaRef?)