From d78c54accd83f2ec81b51cb30f9bdddb845c9ad4 Mon Sep 17 00:00:00 2001 From: TerryE Date: Mon, 26 Mar 2018 03:44:10 +0100 Subject: [PATCH] Fix Lua stack corruption problem --- app/lua/ldo.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/lua/ldo.c b/app/lua/ldo.c index 9a2ddd0e..fa9e9fdc 100644 --- a/app/lua/ldo.c +++ b/app/lua/ldo.c @@ -144,8 +144,11 @@ static void correctstack (lua_State *L, TValue *oldstack) { void luaD_reallocstack (lua_State *L, int newsize) { TValue *oldstack = L->stack; int realsize = newsize + 1 + EXTRA_STACK; + int block_status = is_block_gc(L); lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); + set_block_gc(L); /* The GC MUST be blocked during stack reallocaiton */ luaM_reallocvector(L, L->stack, L->stacksize, realsize, TValue); + if (!block_status) unset_block_gc(L); /* Honour the previous block status */ L->stacksize = realsize; L->stack_last = L->stack+newsize; correctstack(L, oldstack);