diff --git a/3rd/lua/lstring.c b/3rd/lua/lstring.c index 92bc6778..c38e2ccb 100644 --- a/3rd/lua/lstring.c +++ b/3rd/lua/lstring.c @@ -367,6 +367,9 @@ shrstr_expandpage(unsigned int cap) { return; unsigned int osz = s->mask + 1; unsigned int sz = osz * 2; + // overflow check + if (sz == 0) + return; while (sz < cap) sz = sz * 2; struct shrmap_slot * newpage = shrstr_newpage(sz); @@ -655,11 +658,10 @@ luaS_shrinfo(lua_State *L) { lua_pushinteger(L, total.len); // longest lua_pushinteger(L, SSM.n); // space lua_pushinteger(L, slots); // slots - lua_pushnumber(L, v.mean); // average if (v.count > 1) { lua_pushnumber(L, v.m2 / v.count); // variance } else { lua_pushnumber(L, 0); // variance } - return 7; + return 6; } diff --git a/service/debug_console.lua b/service/debug_console.lua index 0335f250..daa2e688 100644 --- a/service/debug_console.lua +++ b/service/debug_console.lua @@ -336,8 +336,8 @@ function COMMAND.cmem() end function COMMAND.shrtbl() - local n, total, longest, space, slots, avg, variance = memory.ssinfo() - return { n = n, total = total, longest = longest, space = space, slots = slots, average = avg, variace = variance } + local n, total, longest, space, slots, variance = memory.ssinfo() + return { n = n, total = total, longest = longest, space = space, slots = slots, average = n / slots, variace = variance } end function COMMAND.ping(address)