From 94b503d95ef00f1e38b58b024ef45bf8973a8746 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 10 Jun 2024 12:09:35 -0300 Subject: Encoding of table indices (hres) must use C indices As the encoding of array indices is (~index), 0 is encoded as -1 and INT_MAX is encoded as INT_MIN. --- ltests.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ltests.c') diff --git a/ltests.c b/ltests.c index 4780673e..57df10e1 100644 --- a/ltests.c +++ b/ltests.c @@ -365,7 +365,7 @@ static void checktable (global_State *g, Table *h) { checkobjrefN(g, hgc, h->metatable); for (i = 0; i < asize; i++) { TValue aux; - arr2obj(h, i + 1, &aux); + arr2obj(h, i, &aux); checkvalref(g, hgc, &aux); } for (n = gnode(h, 0); n < limit; n++) { @@ -1010,7 +1010,7 @@ static int table_query (lua_State *L) { } else if (cast_uint(i) < asize) { lua_pushinteger(L, i); - arr2obj(t, i + 1, s2v(L->top.p)); + arr2obj(t, i, s2v(L->top.p)); api_incr_top(L); lua_pushnil(L); } -- cgit v1.2.3-55-g6feb