commit facb0519a08faec540f81aee045c8e1dbb7e6aed
parent ffdca3522e757f0203b7bdbe5bccb0ae826bfd81
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Mon, 7 Apr 2008 15:44:00 -0300
two bugs: invalid boolean values in constant table + too deep recursion
when reading nested functions
Diffstat:
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/lundump.c b/lundump.c
@@ -1,5 +1,5 @@
/*
-** $Id: lundump.c,v 2.7 2006/02/17 15:51:03 roberto Exp roberto $
+** $Id: lundump.c,v 2.8 2006/09/11 14:07:24 roberto Exp roberto $
** load precompiled Lua chunks
** See Copyright Notice in lua.h
*/
@@ -113,7 +113,7 @@ static void LoadConstants(LoadState* S, Proto* f)
setnilvalue(o);
break;
case LUA_TBOOLEAN:
- setbvalue(o,LoadChar(S));
+ setbvalue(o,LoadChar(S)!=0);
break;
case LUA_TNUMBER:
setnvalue(o,LoadNumber(S));
@@ -159,7 +159,9 @@ static void LoadDebug(LoadState* S, Proto* f)
static Proto* LoadFunction(LoadState* S, TString* p)
{
- Proto* f=luaF_newproto(S->L);
+ Proto* f;
+ if (++G(S->L)->nCcalls > LUAI_MAXCCALLS) error(S, "function nest too deep");
+ f=luaF_newproto(S->L);
setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
f->source=LoadString(S); if (f->source==NULL) f->source=p;
f->linedefined=LoadInt(S);
@@ -173,6 +175,7 @@ static Proto* LoadFunction(LoadState* S, TString* p)
LoadDebug(S,f);
IF (!luaG_checkcode(f), "bad code");
S->L->top--;
+ G(S->L)->nCcalls--;
return f;
}