commit 0782416a747a8ebb3570f3ac84918eaa4386f213
parent 3ca9af51a4f060cf2178901a67a21f8269af3224
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date: Wed, 12 Jul 2006 16:02:27 -0300
bug: wrong limit for list constructors
Diffstat:
2 files changed, 34 insertions(+), 2 deletions(-)
diff --git a/bugs b/bugs
@@ -1013,3 +1013,35 @@ patch = [[
]],
}
+
+Bug{
+what = [[list constructors have wrong limit]],
+
+report = [[by Norman Ramsey, June 2006]],
+
+since = "Lua 5.1",
+
+example = [[
+a = {}
+a[1] = "x={1"
+for i = 2, 2^20 do
+ a[i] = 1
+end
+a[#a + 1] = "}"
+s = table.concat(a, ",")
+assert(loadstring(s))()
+print(#x)
+]],
+
+patch = [[
+* lparser.c:
+ static void listfield (LexState *ls, struct ConsControl *cc) {
+ expr(ls, &cc->v);
+- luaY_checklimit(ls->fs, cc->na, MAXARG_Bx, "items in a constructor");
++ luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
+ cc->na++;
+ cc->tostore++;
+ }
+]],
+
+}
diff --git a/lparser.c b/lparser.c
@@ -1,5 +1,5 @@
/*
-** $Id: lparser.c,v 2.43 2006/06/22 16:12:59 roberto Exp roberto $
+** $Id: lparser.c,v 2.44 2006/07/11 15:53:29 roberto Exp roberto $
** Lua Parser
** See Copyright Notice in lua.h
*/
@@ -495,7 +495,7 @@ static void lastlistfield (FuncState *fs, struct ConsControl *cc) {
static void listfield (LexState *ls, struct ConsControl *cc) {
expr(ls, &cc->v);
- luaY_checklimit(ls->fs, cc->na, MAXARG_Bx, "items in a constructor");
+ luaY_checklimit(ls->fs, cc->na, MAX_INT, "items in a constructor");
cc->na++;
cc->tostore++;
}