Browse Source

two bugs: invalid boolean values in constant table + too deep recursion

when reading nested functions
pull/9/head
Roberto Ierusalimschy 17 years ago
parent
commit
facb0519a0
  1. 9
      lundump.c

9
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 ** load precompiled Lua chunks
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -113,7 +113,7 @@ static void LoadConstants(LoadState* S, Proto* f)
setnilvalue(o); setnilvalue(o);
break; break;
case LUA_TBOOLEAN: case LUA_TBOOLEAN:
setbvalue(o,LoadChar(S)); setbvalue(o,LoadChar(S)!=0);
break; break;
case LUA_TNUMBER: case LUA_TNUMBER:
setnvalue(o,LoadNumber(S)); setnvalue(o,LoadNumber(S));
@ -159,7 +159,9 @@ static void LoadDebug(LoadState* S, Proto* f)
static Proto* LoadFunction(LoadState* S, TString* p) 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); setptvalue2s(S->L,S->L->top,f); incr_top(S->L);
f->source=LoadString(S); if (f->source==NULL) f->source=p; f->source=LoadString(S); if (f->source==NULL) f->source=p;
f->linedefined=LoadInt(S); f->linedefined=LoadInt(S);
@ -173,6 +175,7 @@ static Proto* LoadFunction(LoadState* S, TString* p)
LoadDebug(S,f); LoadDebug(S,f);
IF (!luaG_checkcode(f), "bad code"); IF (!luaG_checkcode(f), "bad code");
S->L->top--; S->L->top--;
G(S->L)->nCcalls--;
return f; return f;
} }

Loading…
Cancel
Save