From eb6fdb866e5ffd467ad0f08fb4bcc50a5af37a22 Mon Sep 17 00:00:00 2001
From: Edwin Mons <edwin.mons@isode.com>
Date: Fri, 23 May 2014 14:52:30 +0200
Subject: Fix crash in Sluift DOMElementConvertor

DOMElementConvertor crashed because the stack wasn't large enough for
deeper nested element trees. Calling lua_checkstack grows the stack if
there's need for it. Normally Lua does this for you, but the
DOMElementConverter can spend quite some time in non-Lua space.

Change-Id: I23e563d49191b1db1204d2f6fa7d30e2e9d05c1f

diff --git a/Sluift/ElementConvertors/DOMElementConvertor.cpp b/Sluift/ElementConvertors/DOMElementConvertor.cpp
index fb1f658..784fcfd 100644
--- a/Sluift/ElementConvertors/DOMElementConvertor.cpp
+++ b/Sluift/ElementConvertors/DOMElementConvertor.cpp
@@ -35,6 +35,7 @@ namespace {
 			virtual void handleStartElement(
 					const std::string& element, const std::string& ns, 
 					const AttributeMap& attributes) SWIFTEN_OVERRIDE {
+				lua_checkstack(L, 6);
 				lua_pushnumber(L, currentIndex);
 				lua_newtable(L);
 				lua_pushstring(L, element.c_str());
@@ -78,6 +79,7 @@ namespace {
 			}
 
 			virtual void handleCharacterData(const std::string& data) SWIFTEN_OVERRIDE {
+				lua_checkstack(L, 2);
 				lua_pushnumber(L, currentIndex);
 				lua_pushstring(L, data.c_str());
 				lua_settable(L, -3);
-- 
cgit v0.10.2-6-g49f6