Browse Source

bug: rawset/rawget do not ignore extra arguments

Roberto Ierusalimschy 20 years ago
parent
commit
6bfef60e77
2 changed files with 24 additions and 1 deletions
  1. 21 0
      bugs
  2. 3 1
      lbaselib.c

+ 21 - 0
bugs

@@ -743,3 +743,24 @@ patch = [[
 ]],
 }
 
+
+Bug{
+what = [[rawset/rawget do not ignore extra arguments]],
+
+report = [[Romulo Bahiense, 11/03/2005]],
+
+example = [[
+a = {}
+rawset(a, 1, 2, 3)
+print(a[1], a[2])    -- should be 2 and nil
+]],
+
+patch = [[
+* lbaselib.c:
+175a176
+>   lua_settop(L, 2);
+183a185
+>   lua_settop(L, 3);
+]],
+}
+

+ 3 - 1
lbaselib.c

@@ -1,5 +1,5 @@
 /*
-** $Id: lbaselib.c,v 1.168 2005/02/23 17:30:22 roberto Exp roberto $
+** $Id: lbaselib.c,v 1.169 2005/02/28 17:24:41 roberto Exp roberto $
 ** Basic library
 ** See Copyright Notice in lua.h
 */
@@ -164,6 +164,7 @@ static int luaB_rawequal (lua_State *L) {
 static int luaB_rawget (lua_State *L) {
   luaL_checktype(L, 1, LUA_TTABLE);
   luaL_checkany(L, 2);
+  lua_settop(L, 2);
   lua_rawget(L, 1);
   return 1;
 }
@@ -172,6 +173,7 @@ static int luaB_rawset (lua_State *L) {
   luaL_checktype(L, 1, LUA_TTABLE);
   luaL_checkany(L, 2);
   luaL_checkany(L, 3);
+  lua_settop(L, 3);
   lua_rawset(L, 1);
   return 1;
 }