overflow check

This commit is contained in:
Cloud Wu
2019-04-03 11:15:33 +08:00
parent 6ab841beec
commit 8e8a92ca2d

View File

@@ -367,11 +367,12 @@ shrstr_expandpage(int cap) {
return;
int osz = s->mask + 1;
int sz = osz * 2;
// overflow check
if (sz <= 0)
return;
while (sz < cap)
while (sz < cap) {
// overflow check
if (sz <= 0)
return;
sz = sz * 2;
}
struct shrmap_slot * newpage = shrstr_newpage(sz);
rwlock_wlock(&s->lock);
int succ = shrstr_allocpage(s, osz, sz, newpage);