[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: unpack segfault
- From: "Patrick Donnelly" <batrick.donnelly@...>
- Date: Tue, 12 Feb 2008 20:18:47 -0700
Actually that's not a good patch... that just means you use
return unpack({1,2,3}, 2^32-1, 2^32-1)
instead to cause a segfault. Better patch below!
--- lbaselib.c.old 2008-02-12 17:06:51.000000000 -0700
+++ lbaselib.c 2008-02-12 20:16:20.000000000 -0700
@@ -344,6 +344,10 @@
luaL_checktype(L, 1, LUA_TTABLE);
i = luaL_optint(L, 2, 1);
e = luaL_opt(L, luaL_checkint, 3, luaL_getn(L, 1));
+ if (i == e) {
+ lua_rawgeti(L, 1, i);
+ return 1;
+ }
n = e - i + 1; /* number of elements */
if (n <= 0) return 0; /* empty range */
luaL_checkstack(L, n, "table too big to unpack");
Cheers,
--
-Patrick Donnelly
"One of the lessons of history is that nothing is often a good thing
to do and always a clever thing to say."
-Will Durant