mirror of https://github.com/rusefi/lua.git
macro 'checkobjref' accepts NULL (as all its uses checked for NULL
before) + user value from a userdata may not be a GC object
This commit is contained in:
parent
fa3113ffbf
commit
3fc25ff15b
28
ltests.c
28
ltests.c
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
** $Id: ltests.c,v 2.170 2014/05/13 19:40:28 roberto Exp roberto $
|
** $Id: ltests.c,v 2.171 2014/06/10 17:41:38 roberto Exp roberto $
|
||||||
** Internal Module for Debugging of the Lua Implementation
|
** Internal Module for Debugging of the Lua Implementation
|
||||||
** See Copyright Notice in lua.h
|
** See Copyright Notice in lua.h
|
||||||
*/
|
*/
|
||||||
|
@ -207,7 +207,8 @@ static int testobjref (global_State *g, GCObject *f, GCObject *t) {
|
||||||
return r1;
|
return r1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define checkobjref(g,f,t) lua_assert(testobjref(g,f,obj2gco(t)))
|
#define checkobjref(g,f,t) \
|
||||||
|
lua_assert((t) == NULL || testobjref(g,f,obj2gco(t)))
|
||||||
|
|
||||||
|
|
||||||
static void checkvalref (global_State *g, GCObject *f, const TValue *t) {
|
static void checkvalref (global_State *g, GCObject *f, const TValue *t) {
|
||||||
|
@ -220,7 +221,6 @@ static void checktable (global_State *g, Table *h) {
|
||||||
int i;
|
int i;
|
||||||
Node *n, *limit = gnode(h, sizenode(h));
|
Node *n, *limit = gnode(h, sizenode(h));
|
||||||
GCObject *hgc = obj2gco(h);
|
GCObject *hgc = obj2gco(h);
|
||||||
if (h->metatable)
|
|
||||||
checkobjref(g, hgc, h->metatable);
|
checkobjref(g, hgc, h->metatable);
|
||||||
for (i = 0; i < h->sizearray; i++)
|
for (i = 0; i < h->sizearray; i++)
|
||||||
checkvalref(g, hgc, &h->array[i]);
|
checkvalref(g, hgc, &h->array[i]);
|
||||||
|
@ -241,25 +241,19 @@ static void checktable (global_State *g, Table *h) {
|
||||||
static void checkproto (global_State *g, Proto *f) {
|
static void checkproto (global_State *g, Proto *f) {
|
||||||
int i;
|
int i;
|
||||||
GCObject *fgc = obj2gco(f);
|
GCObject *fgc = obj2gco(f);
|
||||||
if (f->cache) checkobjref(g, fgc, f->cache);
|
checkobjref(g, fgc, f->cache);
|
||||||
if (f->source) checkobjref(g, fgc, f->source);
|
checkobjref(g, fgc, f->source);
|
||||||
for (i=0; i<f->sizek; i++) {
|
for (i=0; i<f->sizek; i++) {
|
||||||
if (ttisstring(f->k+i))
|
if (ttisstring(f->k+i))
|
||||||
checkobjref(g, fgc, rawtsvalue(f->k+i));
|
checkobjref(g, fgc, rawtsvalue(f->k+i));
|
||||||
}
|
}
|
||||||
for (i=0; i<f->sizeupvalues; i++) {
|
for (i=0; i<f->sizeupvalues; i++)
|
||||||
if (f->upvalues[i].name)
|
|
||||||
checkobjref(g, fgc, f->upvalues[i].name);
|
checkobjref(g, fgc, f->upvalues[i].name);
|
||||||
}
|
for (i=0; i<f->sizep; i++)
|
||||||
for (i=0; i<f->sizep; i++) {
|
|
||||||
if (f->p[i])
|
|
||||||
checkobjref(g, fgc, f->p[i]);
|
checkobjref(g, fgc, f->p[i]);
|
||||||
}
|
for (i=0; i<f->sizelocvars; i++)
|
||||||
for (i=0; i<f->sizelocvars; i++) {
|
|
||||||
if (f->locvars[i].varname)
|
|
||||||
checkobjref(g, fgc, f->locvars[i].varname);
|
checkobjref(g, fgc, f->locvars[i].varname);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -274,7 +268,7 @@ static void checkCclosure (global_State *g, CClosure *cl) {
|
||||||
static void checkLclosure (global_State *g, LClosure *cl) {
|
static void checkLclosure (global_State *g, LClosure *cl) {
|
||||||
GCObject *clgc = obj2gco(cl);
|
GCObject *clgc = obj2gco(cl);
|
||||||
int i;
|
int i;
|
||||||
if (cl->p) checkobjref(g, clgc, cl->p);
|
checkobjref(g, clgc, cl->p);
|
||||||
for (i=0; i<cl->nupvalues; i++) {
|
for (i=0; i<cl->nupvalues; i++) {
|
||||||
UpVal *uv = cl->upvals[i];
|
UpVal *uv = cl->upvals[i];
|
||||||
if (uv) {
|
if (uv) {
|
||||||
|
@ -324,9 +318,9 @@ static void checkobject (global_State *g, GCObject *o, int maybedead) {
|
||||||
case LUA_TUSERDATA: {
|
case LUA_TUSERDATA: {
|
||||||
TValue uservalue;
|
TValue uservalue;
|
||||||
Table *mt = gco2u(o)->metatable;
|
Table *mt = gco2u(o)->metatable;
|
||||||
if (mt) checkobjref(g, o, mt);
|
checkobjref(g, o, mt);
|
||||||
getuservalue(g->mainthread, rawgco2u(o), &uservalue);
|
getuservalue(g->mainthread, rawgco2u(o), &uservalue);
|
||||||
checkobjref(g, o, &uservalue);
|
checkvalref(g, o, &uservalue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case LUA_TTABLE: {
|
case LUA_TTABLE: {
|
||||||
|
|
Loading…
Reference in New Issue