From de84b3fecb9eb96f2d65bb754851dba8d815bb6d Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Thu, 27 Feb 2014 15:56:15 -0300 Subject: store number of upvalues of main function in front of the dump, so that undump can create initial closure before reading its prototype --- lundump.c | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) (limited to 'lundump.c') diff --git a/lundump.c b/lundump.c index 25e98dd6..a976e6dd 100644 --- a/lundump.c +++ b/lundump.c @@ -1,5 +1,5 @@ /* -** $Id: lundump.c,v 2.25 2014/02/13 12:11:34 roberto Exp roberto $ +** $Id: lundump.c,v 2.26 2014/02/27 16:56:20 roberto Exp roberto $ ** load precompiled Lua chunks ** See Copyright Notice in lua.h */ @@ -238,17 +238,11 @@ Closure* luaU_undump (lua_State* L, ZIO* Z, Mbuffer* buff, const char* name) S.Z=Z; S.b=buff; checkHeader(&S); - cl=luaF_newLclosure(L,1); + cl=luaF_newLclosure(L,LoadByte(&S)); setclLvalue(L,L->top,cl); incr_top(L); cl->l.p=luaF_newproto(L); LoadFunction(&S,cl->l.p); - if (cl->l.p->sizeupvalues != 1) - { - Proto* p=cl->l.p; - cl=luaF_newLclosure(L,cl->l.p->sizeupvalues); - cl->l.p=p; - setclLvalue(L,L->top-1,cl); - } + lua_assert(cl->l.nupvalues==cl->l.p->sizeupvalues); luai_verifycode(L,buff,cl->l.p); return cl; } -- cgit v1.2.3-55-g6feb