aboutsummaryrefslogtreecommitdiff
path: root/bugs
diff options
context:
space:
mode:
Diffstat (limited to 'bugs')
-rw-r--r--bugs25
1 files changed, 25 insertions, 0 deletions
diff --git a/bugs b/bugs
index b9015051..ed2eb666 100644
--- a/bugs
+++ b/bugs
@@ -1570,6 +1570,31 @@ lstrlib.c:
1570} 1570}
1571 1571
1572Bug{ 1572Bug{
1573what = [[table.remove removes last element of a table when given
1574an out-of-bound index]],
1575report = [[Patrick Donnelly, on 11/2007]],
1576since = [[at least 5.0]],
1577example = [[
1578a = {1,2,3}
1579table.remove(a, 4)
1580print(a[3]) --> nil (should be 3)
1581]],
1582patch = [[
1583ltablib.c:
1584@@ -118,7 +118,8 @@
1585 static int tremove (lua_State *L) {
1586 int e = aux_getn(L, 1);
1587 int pos = luaL_optint(L, 2, e);
1588- if (e == 0) return 0; /* table is `empty' */
1589+ if (!(1 <= pos && pos <= e)) /* position is outside bounds? */
1590+ return 0; /* nothing to remove */
1591 luaL_setn(L, 1, e - 1); /* t.n = n-1 */
1592 lua_rawgeti(L, 1, pos); /* result = t[pos] */
1593 for ( ;pos<e; pos++) {
1594]],
1595}
1596
1597Bug{
1573what = [[ ]], 1598what = [[ ]],
1574report = [[ , on ]], 1599report = [[ , on ]],
1575since = [[i ]], 1600since = [[i ]],