diff --git a/luprex/eris-master/src/eris.c b/luprex/eris-master/src/eris.c index a452392a..e153f8c7 100644 --- a/luprex/eris-master/src/eris.c +++ b/luprex/eris-master/src/eris.c @@ -1292,18 +1292,21 @@ u_proto(Info *info) { /* ... proto */ } poppath(info); - /* Read child protos. */ + /* Allocate space for child protos */ + /* Null all entries to avoid confusing the GC. */ int sizep = READ_VALUE(int); eris_reallocvector(info->L, p->p, 0, sizep, Proto*); + memset(p->p, 0, sizep * sizeof(Proto*)); p->sizep = sizep; - /* Null all entries to avoid confusing the GC. */ - memset(p->p, 0, p->sizep * sizeof(Proto*)); + + /* Read child protos. */ pushpath(info, ".protos"); for (i = 0, n = p->sizep; i < n; ++i) { Proto *cp; pushpath(info, "[%d]", i); - p->p[i] = eris_newproto(info->L); - lua_pushlightuserdata(info->L, (void*)p->p[i]); /* ... proto nproto */ + p->p[i] = cp = eris_newproto(info->L); + luaC_objbarrier(info->L, p, cp); + lua_pushlightuserdata(info->L, (void*)cp); /* ... proto nproto */ unpersist(info); /* ... proto nproto nproto/oproto */ cp = (Proto*)lua_touserdata(info->L, -1); if (cp != p->p[i]) { /* ... proto nproto oproto */