Browse Source

API functions check stack overflow

Roberto Ierusalimschy 25 years ago
parent
commit
2779e81fbb
2 changed files with 7 additions and 5 deletions
  1. 4 3
      lapi.c
  2. 3 2
      ltm.c

+ 4 - 3
lapi.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lapi.c,v 1.93 2000/08/31 21:01:43 roberto Exp roberto $
+** $Id: lapi.c,v 1.94 2000/09/05 19:33:32 roberto Exp roberto $
 ** Lua API
 ** See Copyright Notice in lua.h
 */
@@ -30,7 +30,7 @@ const char lua_ident[] = "$Lua: " LUA_VERSION " " LUA_COPYRIGHT " $\n"
 
 #define Index(L,i)	((i) >= 0 ? (L->Cbase+((i)-1)) : (L->top+(i)))
 
-#define api_incr_top(L)	(++L->top)
+#define api_incr_top(L)	incr_top
 
 
 
@@ -250,7 +250,8 @@ void lua_pushusertag (lua_State *L, void *u, int tag) {  /* ORDER LUA_T */
 void lua_getglobal (lua_State *L, const char *name) {
   StkId top = L->top;
   *top = *luaV_getglobal(L, luaS_new(L, name));
-  L->top = top+1;
+  L->top = top;
+  api_incr_top(L);
 }
 
 

+ 3 - 2
ltm.c

@@ -1,5 +1,5 @@
 /*
-** $Id: ltm.c,v 1.46 2000/08/09 19:16:57 roberto Exp roberto $
+** $Id: ltm.c,v 1.47 2000/09/05 19:33:32 roberto Exp roberto $
 ** Tag methods
 ** See Copyright Notice in lua.h
 */
@@ -11,6 +11,7 @@
 #include "lua.h"
 
 #include "lauxlib.h"
+#include "ldo.h"
 #include "lmem.h"
 #include "lobject.h"
 #include "lstate.h"
@@ -127,7 +128,7 @@ void lua_gettagmethod (lua_State *L, int t, const char *event) {
     *L->top = *luaT_getim(L, t,e);
   else
     ttype(L->top) = TAG_NIL;
-  L->top++;
+  incr_top;
 }