ソースを参照

BUG: "lua_getstring" may create a new string, so should check GC

Roberto Ierusalimschy 27 年 前
コミット
b3b7cf7335
2 ファイル変更8 行追加1 行削除
  1. 5 0
      bugs
  2. 3 1
      lapi.c

+ 5 - 0
bugs

@@ -24,3 +24,8 @@ Tue Jan 27 15:27:49 EDT 1998
 >> formats like "%020d" were considered too big (3 algarithms); moreover,
 >> formats like "%020d" were considered too big (3 algarithms); moreover,
 >> some sistems limit printf to at most 500 chars, so we can limit sizes
 >> some sistems limit printf to at most 500 chars, so we can limit sizes
 >> to 2 digits (99).
 >> to 2 digits (99).
+
+** lapi.c
+Tue Jan 27 17:12:36 EDT 1998
+>> "lua_getstring" may create a new string, so should check GC
+

+ 3 - 1
lapi.c

@@ -1,5 +1,5 @@
 /*
 /*
-** $Id: lapi.c,v 1.18 1998/01/07 16:26:48 roberto Exp roberto $
+** $Id: lapi.c,v 1.19 1998/01/09 14:44:55 roberto Exp roberto $
 ** Lua API
 ** Lua API
 ** See Copyright Notice in lua.h
 ** See Copyright Notice in lua.h
 */
 */
@@ -287,6 +287,7 @@ double lua_getnumber (lua_Object object)
 
 
 char *lua_getstring (lua_Object object)
 char *lua_getstring (lua_Object object)
 {
 {
+  luaC_checkGC();  /* "tostring" may create a new string */
   if (object == LUA_NOOBJECT || tostring(Address(object)))
   if (object == LUA_NOOBJECT || tostring(Address(object)))
     return NULL;
     return NULL;
   else return (svalue(Address(object)));
   else return (svalue(Address(object)));
@@ -341,6 +342,7 @@ void lua_pushCclosure (lua_CFunction fn, int n)
   fvalue(L->stack.top) = fn;
   fvalue(L->stack.top) = fn;
   incr_top;
   incr_top;
   luaV_closure(n);
   luaV_closure(n);
+  luaC_checkGC();
 }
 }
 
 
 void lua_pushusertag (void *u, int tag)
 void lua_pushusertag (void *u, int tag)