Ver Fonte

Fix undefined behavior in table resizing calculation.

Mike Pall há 16 anos atrás
pai
commit
c56811bb7a
1 ficheiros alterados com 2 adições e 1 exclusões
  1. 2 1
      src/lj_tab.c

+ 2 - 1
src/lj_tab.c

@@ -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;