moai/moai-dev — pull request #733 by superquadratic (2013-08-12 13:59:53+00:00)
Title: Avoid (some) Lua stack overflows

[According to the Lua manual](http://www.lua.org/manual/5.1/manual.html#3.2), _"you are responsible for controlling stack overflow"_, especially when pushing elements onto the stack in a loop. A sufficient stack size can be ensured by calling `lua_checkstack()`. Pushing too many elements onto the stack does not crash immediately, but will corrupt the heap, potentially causing random crashes later. See [this forum post](http://getmoai.com/forums/post7274.html) for two examples of intermittent random crashes.

I added `lua_checkstack()` calls for the following methods:
* `MOAIPartitionResultBuffer::PushProps()`
* `MOAIPathTerrainDeck:getTerrainVec()`
* `MOAITouchSensor:getActiveTouches()`

The following methods can also cause Lua stack overflows, unfortunately these are a bit more tricky to fix:
* `MOAIStream:readFormat()`
* `MOAIXmlParser::Parse()`