Skip to content

Commit 50e48f8

Browse files
committed
Add null pointer check for NC_hashmap table allocation
1 parent 2ec6c18 commit 50e48f8

File tree

2 files changed

+3
-0
lines changed

2 files changed

+3
-0
lines changed

libdispatch/nchashmap.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ NC_hashmapnew(size_t startsize)
186186
if(startsize == 0) {nullfree(hm); return 0;}
187187
}
188188
hm->table = (NC_hentry*)calloc(sizeof(NC_hentry), (size_t)startsize);
189+
if(hm->table == NULL) {nullfree(hm);return 0;}
189190
hm->alloc = startsize;
190191
hm->active = 0;
191192
return hm;

libsrc/v1hpg.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1203,6 +1203,8 @@ v1h_get_NC_vararray(v1hs *gsp, NC_vararray *ncap)
12031203
ncap->nalloc = ncap->nelems;
12041204

12051205
ncap->hashmap = NC_hashmapnew(ncap->nelems);
1206+
if (ncap->hashmap == NULL)
1207+
return NC_ENOMEM;
12061208
{
12071209
NC_var **vpp = ncap->value;
12081210
NC_var *const *const end = &vpp[ncap->nelems];

0 commit comments

Comments
 (0)