aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-25 09:43:52 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-02-25 09:43:52 -0300
commitf055a9dffd9ba403a99266a662b9992bc89dcaa1 (patch)
treefa7f97eaeb3a1e9b32bb28aeda782ac32c5839cc
parent4a7fe61806b266d895c0d2a4725dc427315022bb (diff)
downloadlua-f055a9dffd9ba403a99266a662b9992bc89dcaa1.tar.gz
lua-f055a9dffd9ba403a99266a662b9992bc89dcaa1.tar.bz2
lua-f055a9dffd9ba403a99266a662b9992bc89dcaa1.zip
added check in 'obj2gco' to prevent its use in non Lua-object pointers
(otherwise its cast is blind, casting any value given to it)
-rw-r--r--lstate.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/lstate.h b/lstate.h
index 06581b01..974249de 100644
--- a/lstate.h
+++ b/lstate.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lstate.h,v 2.155 2018/02/15 18:06:24 roberto Exp roberto $ 2** $Id: lstate.h,v 2.156 2018/02/17 19:29:29 roberto Exp roberto $
3** Global State 3** Global State
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -252,8 +252,11 @@ union GCUnion {
252#define gco2upv(o) check_exp((o)->tt == LUA_TUPVAL, &((cast_u(o))->upv)) 252#define gco2upv(o) check_exp((o)->tt == LUA_TUPVAL, &((cast_u(o))->upv))
253 253
254 254
255/* macro to convert a Lua object into a GCObject */ 255/*
256#define obj2gco(v) (&(cast_u(v)->gc)) 256** macro to convert a Lua object into a GCObject
257** (The access to 'tt' tries to ensure that 'v' is actually a Lua object.)
258*/
259#define obj2gco(v) check_exp((v)->tt >= LUA_TSTRING, &(cast_u(v)->gc))
257 260
258 261
259/* actual number of total bytes allocated */ 262/* actual number of total bytes allocated */