diff --git a/3rd/lua/lgc.c b/3rd/lua/lgc.c index fd33b166..44accb59 100644 --- a/3rd/lua/lgc.c +++ b/3rd/lua/lgc.c @@ -492,15 +492,19 @@ static int marksharedproto (global_State *g, SharedProto *f) { ** NULL, so the use of 'markobjectN') */ static int traverseproto (global_State *g, Proto *f) { - int i; + int i,nk,np; if (f->cache && iswhite(f->cache)) f->cache = NULL; /* allow cache to be collected */ - for (i = 0; i < f->sp->sizek; i++) /* mark literals */ + if (f->sp == NULL) + return sizeof(Proto); + nk = (f->k == NULL) ? 0 : f->sp->sizek; + np = (f->p == NULL) ? 0 : f->sp->sizep; + for (i = 0; i < nk; i++) /* mark literals */ markvalue(g, &f->k[i]); - for (i = 0; i < f->sp->sizep; i++) /* mark nested protos */ + for (i = 0; i < np; i++) /* mark nested protos */ markobjectN(g, f->p[i]); - return sizeof(Proto) + sizeof(Proto *) * f->sp->sizep + - sizeof(TValue) * f->sp->sizek + + return sizeof(Proto) + sizeof(Proto *) * np + + sizeof(TValue) * nk + marksharedproto(g, f->sp); } diff --git a/test/testmemlimit.lua b/test/testmemlimit.lua index 66d972d1..5c0c10d5 100644 --- a/test/testmemlimit.lua +++ b/test/testmemlimit.lua @@ -16,7 +16,10 @@ skynet.start(function() end) local libs = {} for k,v in ipairs(names) do - libs[v] = require(v) + local ok, m = pcall(require, v) + if ok then + libs[v] = m + end end skynet.error(limit, err) skynet.exit()