Fix undefined behavior in table resizing calculation.

This commit is contained in:
Mike Pall 2010-01-21 19:42:51 +01:00
parent 419cbb3aa9
commit c56811bb7a

View File

@ -357,7 +357,8 @@ static void rehashtab(lua_State *L, GCtab *t, cTValue *ek)
uint32_t total, asize, na, i;
for (i = 0; i < LJ_MAX_ABITS; i++) bins[i] = 0;
asize = countarray(t, bins);
total = 1 + asize + counthash(t, bins, &asize);
total = 1 + asize;
total += counthash(t, bins, &asize);
asize += countint(ek, bins);
na = bestasize(bins, &asize);
total -= na;