Avoid out-of-range number of results when compiling select(k, ...).

The interpreter will throw and abort the trace, anyway.
This commit is contained in:
Mike Pall 2021-07-19 17:03:16 +02:00
parent 44bd7437a2
commit 6ca580155b

View File

@ -256,9 +256,9 @@ static void LJ_FASTCALL recff_select(jit_State *J, RecordFFData *rd)
ptrdiff_t n = (ptrdiff_t)J->maxslot;
if (start < 0) start += n;
else if (start > n) start = n;
rd->nres = n - start;
if (start >= 1) {
ptrdiff_t i;
rd->nres = n - start;
for (i = 0; i < n - start; i++)
J->base[i] = J->base[start+i];
} /* else: Interpreter will throw. */