Skip to content

Commit

Permalink
OOM check
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudwu committed Apr 3, 2019
1 parent 8e8a92c commit fbd932e
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 3rd/lua/lstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,8 @@ static struct shrmap_slot *
shrstr_newpage(int sz) {
int i;
struct shrmap_slot * s = (struct shrmap_slot *)malloc(sz * sizeof(*s));
if (s == NULL)
return NULL;
for (i=0;i<sz;i++) {
rwlock_init(&s[i].lock);
s[i].str = NULL;
Expand Down Expand Up @@ -374,6 +376,8 @@ shrstr_expandpage(int cap) {
sz = sz * 2;
}
struct shrmap_slot * newpage = shrstr_newpage(sz);
if (newpage == NULL)
return;
rwlock_wlock(&s->lock);
int succ = shrstr_allocpage(s, osz, sz, newpage);
rwlock_wunlock(&s->lock);
Expand Down

0 comments on commit fbd932e

Please sign in to comment.