Skip to content

Commit

Permalink
overflow check
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwu committed Apr 3, 2019
1 parent 6ab841b commit 8e8a92c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions 3rd/lua/lstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 8e8a92c

Please sign in to comment.