diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-25 09:43:52 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-02-25 09:43:52 -0300 |
| commit | f055a9dffd9ba403a99266a662b9992bc89dcaa1 (patch) | |
| tree | fa7f97eaeb3a1e9b32bb28aeda782ac32c5839cc | |
| parent | 4a7fe61806b266d895c0d2a4725dc427315022bb (diff) | |
| download | lua-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.h | 9 |
1 files changed, 6 insertions, 3 deletions
| @@ -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 */ |
