tighter tests for stack overflow

This commit is contained in:
Roberto Ierusalimschy
2004-09-08 11:23:09 -03:00
parent ee165043ef
commit 0de2065f4e
4 changed files with 37 additions and 24 deletions

6
ldo.h
View File

@@ -1,5 +1,5 @@
/*
** $Id: ldo.h,v 2.1 2003/12/10 12:13:36 roberto Exp roberto $
** $Id: ldo.h,v 2.2 2004/05/14 19:25:09 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@@ -17,7 +17,7 @@
** macro to control inclusion of some hard tests on stack reallocation
*/
#ifndef HARDSTACKTESTS
#define condhardstacktests(x) { /* empty */ }
#define condhardstacktests(x) ((void)0)
#else
#define condhardstacktests(x) x
#endif
@@ -26,7 +26,7 @@
#define luaD_checkstack(L,n) \
if ((char *)L->stack_last - (char *)L->top <= (n)*(int)sizeof(TValue)) \
luaD_growstack(L, n); \
else condhardstacktests(luaD_reallocstack(L, L->stacksize));
else condhardstacktests(luaD_reallocstack(L, L->stacksize - EXTRA_STACK - 1));
#define incr_top(L) {luaD_checkstack(L,1); L->top++;}