From d412b1ea9f9c2568ed83e85e6d893368ac12537a Mon Sep 17 00:00:00 2001
From: Benoit Germain <bnt period germain arrobase gmail period com>
Date: Fri, 24 Jan 2014 11:08:46 +0100
Subject: another Lua stack overflow fix

---
 src/tools.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

(limited to 'src')

diff --git a/src/tools.c b/src/tools.c
index e456db7..fc3e7e0 100644
--- a/src/tools.c
+++ b/src/tools.c
@@ -1559,6 +1559,7 @@ static void lookup_native_func( lua_State* L2, lua_State* L, uint_t i, enum eLoo
 	size_t len;
 	ASSERT_L( lua_isfunction( L, i));                        // ... f ...
 	STACK_CHECK( L);
+	STACK_GROW( L, 3); // up to 3 slots are necessary on error
 	if( mode_ == eLM_FromKeeper)
 	{
 		lua_CFunction f = lua_tocfunction( L, i); // should *always* be sentinelfunc!
@@ -1609,7 +1610,7 @@ static void lookup_native_func( lua_State* L2, lua_State* L, uint_t i, enum eLoo
 	STACK_END( L, 0);
 	// push the equivalent function in the destination's stack, retrieved from the lookup table
 	STACK_CHECK( L2);
-	STACK_GROW( L2, 2);
+	STACK_GROW( L2, 3); // up to 3 slots are necessary on error
 	if( mode_ == eLM_ToKeeper)
 	{
 		// push a sentinel closure that holds the lookup name as upvalue
-- 
cgit v1.2.3-55-g6feb