浏览代码

BUG: seg. fault when rawget/rawset get extra arguments

Roberto Ierusalimschy 23 年之前
父节点
当前提交
9d2e454d6f
共有 2 个文件被更改,包括 10 次插入3 次删除
  1. 7 0
      bugs
  2. 3 3
      lbaselib.c

+ 7 - 0
bugs

@@ -270,3 +270,10 @@ Tue Jul 10 16:59:18 EST 2001
 >> error message for `%a' gave wrong line number
 >> error message for `%a' gave wrong line number
 (by Leonardo Constantino; since 4.0)
 (by Leonardo Constantino; since 4.0)
 
 
+** lbaselib.c
+Fri Dec 21 15:21:05 EDT 2001
+>> seg. fault when rawget/rawset get extra arguments
+(by Eric Mauger; since 4.0b)
+
+
+

+ 3 - 3
lbaselib.c

@@ -185,7 +185,7 @@ static int luaB_globals (lua_State *L) {
 static int luaB_rawget (lua_State *L) {
 static int luaB_rawget (lua_State *L) {
   luaL_check_type(L, 1, LUA_TTABLE);
   luaL_check_type(L, 1, LUA_TTABLE);
   luaL_check_any(L, 2);
   luaL_check_any(L, 2);
-  lua_rawget(L, -2);
+  lua_rawget(L, 1);
   return 1;
   return 1;
 }
 }
 
 
@@ -193,7 +193,7 @@ static int luaB_rawset (lua_State *L) {
   luaL_check_type(L, 1, LUA_TTABLE);
   luaL_check_type(L, 1, LUA_TTABLE);
   luaL_check_any(L, 2);
   luaL_check_any(L, 2);
   luaL_check_any(L, 3);
   luaL_check_any(L, 3);
-  lua_rawset(L, -3);
+  lua_rawset(L, 1);
   return 1;
   return 1;
 }
 }
 
 
@@ -449,7 +449,7 @@ static int luaB_foreachi (lua_State *L) {
 static int luaB_foreach (lua_State *L) {
 static int luaB_foreach (lua_State *L) {
   luaL_check_type(L, 1, LUA_TTABLE);
   luaL_check_type(L, 1, LUA_TTABLE);
   luaL_check_type(L, 2, LUA_TFUNCTION);
   luaL_check_type(L, 2, LUA_TFUNCTION);
-  lua_pushnil(L);  /* first index */
+  lua_pushnil(L);  /* first key */
   for (;;) {
   for (;;) {
     if (lua_next(L, 1) == 0)
     if (lua_next(L, 1) == 0)
       return 0;
       return 0;