mirror of
https://github.com/lua/lua
synced 2025-01-21 00:22:04 +03:00
should not manipulate NULL pointers (even without accessing them)
This commit is contained in:
parent
850c60e81b
commit
593bfc9668
6
lfunc.c
6
lfunc.c
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lfunc.c,v 2.11 2005/05/05 20:47:02 roberto Exp roberto $
|
||||
** $Id: lfunc.c,v 2.12 2005/12/22 16:19:56 roberto Exp roberto $
|
||||
** Auxiliary functions to manipulate prototypes and closures
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -55,7 +55,7 @@ UpVal *luaF_findupval (lua_State *L, StkId level) {
|
||||
GCObject **pp = &L->openupval;
|
||||
UpVal *p;
|
||||
UpVal *uv;
|
||||
while ((p = ngcotouv(*pp)) != NULL && p->v >= level) {
|
||||
while (*pp != NULL && (p = ngcotouv(*pp))->v >= level) {
|
||||
lua_assert(p->v != &p->u.value);
|
||||
if (p->v == level) { /* found a corresponding upvalue? */
|
||||
if (isdead(g, obj2gco(p))) /* is it dead? */
|
||||
@ -96,7 +96,7 @@ void luaF_freeupval (lua_State *L, UpVal *uv) {
|
||||
void luaF_close (lua_State *L, StkId level) {
|
||||
UpVal *uv;
|
||||
global_State *g = G(L);
|
||||
while ((uv = ngcotouv(L->openupval)) != NULL && uv->v >= level) {
|
||||
while (L->openupval != NULL && (uv = ngcotouv(L->openupval))->v >= level) {
|
||||
GCObject *o = obj2gco(uv);
|
||||
lua_assert(!isblack(o) && uv->v != &uv->u.value);
|
||||
L->openupval = uv->next; /* remove from `open' list */
|
||||
|
5
lstate.h
5
lstate.h
@ -1,5 +1,5 @@
|
||||
/*
|
||||
** $Id: lstate.h,v 2.26 2006/08/15 19:59:20 roberto Exp roberto $
|
||||
** $Id: lstate.h,v 2.27 2006/09/19 13:57:50 roberto Exp roberto $
|
||||
** Global State
|
||||
** See Copyright Notice in lua.h
|
||||
*/
|
||||
@ -156,8 +156,7 @@ union GCObject {
|
||||
#define gco2h(o) check_exp((o)->gch.tt == LUA_TTABLE, &((o)->h))
|
||||
#define gco2p(o) check_exp((o)->gch.tt == LUA_TPROTO, &((o)->p))
|
||||
#define gco2uv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
|
||||
#define ngcotouv(o) \
|
||||
check_exp((o) == NULL || (o)->gch.tt == LUA_TUPVAL, &((o)->uv))
|
||||
#define ngcotouv(o) check_exp((o)->gch.tt == LUA_TUPVAL, &((o)->uv))
|
||||
#define gco2th(o) check_exp((o)->gch.tt == LUA_TTHREAD, &((o)->th))
|
||||
|
||||
/* macro to convert any Lua object into a GCObject */
|
||||
|
Loading…
Reference in New Issue
Block a user