checkstack needs a correct stack

This commit is contained in:
Roberto Ierusalimschy 2000-08-22 17:53:30 -03:00
parent b800c38b69
commit 3723d790ae
1 changed files with 3 additions and 1 deletions

4
lvm.c
View File

@ -1,5 +1,5 @@
/* /*
** $Id: lvm.c,v 1.127 2000/08/14 14:05:06 roberto Exp roberto $ ** $Id: lvm.c,v 1.128 2000/08/22 20:49:29 roberto Exp roberto $
** Lua virtual machine ** Lua virtual machine
** See Copyright Notice in lua.h ** See Copyright Notice in lua.h
*/ */
@ -176,6 +176,7 @@ void luaV_getglobal (lua_State *L, TString *s, StkId top) {
if (ttype(im) == TAG_NIL) /* is there a tag method? */ if (ttype(im) == TAG_NIL) /* is there a tag method? */
*top = *value; /* default behavior */ *top = *value; /* default behavior */
else { /* tag method */ else { /* tag method */
L->top = top;
luaD_checkstack(L, 3); luaD_checkstack(L, 3);
*top = *im; *top = *im;
ttype(top+1) = TAG_STRING; ttype(top+1) = TAG_STRING;
@ -203,6 +204,7 @@ void luaV_setglobal (lua_State *L, TString *s, StkId top) {
} }
} }
else { else {
L->top = top;
luaD_checkstack(L, 3); luaD_checkstack(L, 3);
*(top+2) = *(top-1); /* new value */ *(top+2) = *(top-1); /* new value */
*(top+1) = *oldvalue; *(top+1) = *oldvalue;