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.
This commit is contained in:
Roberto Ierusalimschy
2024-06-10 12:09:35 -03:00
parent bdc85357aa
commit 94b503d95e
4 changed files with 30 additions and 24 deletions

2
lvm.c
View File

@@ -1857,7 +1857,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) {
luaH_resizearray(L, h, last); /* preallocate it at once */
for (; n > 0; n--) {
TValue *val = s2v(ra + n);
obj2arr(h, last, val);
obj2arr(h, last - 1, val);
last--;
luaC_barrierback(L, obj2gco(h), val);
}