From 56137d58ff7abe8cb22ee3469366e08888c84f28 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Fri, 18 Jul 2014 09:17:54 -0300 Subject: added check for conversion 'obj2gco' (and corrections for small problems detected by this check) --- lstate.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'lstate.h') diff --git a/lstate.h b/lstate.h index dafaefea..69c91b63 100644 --- a/lstate.h +++ b/lstate.h @@ -1,5 +1,5 @@ /* -** $Id: lstate.h,v 2.109 2014/07/17 17:09:50 roberto Exp roberto $ +** $Id: lstate.h,v 2.110 2014/07/17 17:27:49 roberto Exp roberto $ ** Global State ** See Copyright Notice in lua.h */ @@ -170,7 +170,7 @@ struct lua_State { /* -** Union of all collectable objects +** Union of all collectable objects (only for conversions) */ union GCUnion { GCObject gc; /* common header */ @@ -200,8 +200,16 @@ union GCUnion { #define gco2th(o) check_exp((o)->tt == LUA_TTHREAD, &((cast_u(o))->th)) -/* macro to convert any Lua object into a GCObject */ -#define obj2gco(v) (&(cast_u(v)->gc)) +/* macro to convert a Lua object into a GCObject */ +#define obj2gco(v) \ + check_exp(novariant((v)->tt) < LUA_TDEADKEY, (&(cast_u(v)->gc))) + +/* +** macro to convert a TString into a GCObject. +** (TString is a union, and therefore needs an access slightly different +** from the other objects.) +*/ +#define ts2gco(v) (obj2gco(&(v)->tsv)) /* actual number of total bytes allocated */ -- cgit v1.2.3-55-g6feb