Skip to content

Commit f36e4fe

Browse files
committed
prevent possible overflow of next_pow2
1 parent b02280e commit f36e4fe

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

src/iso_alloc.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,11 @@ INTERNAL_HIDDEN iso_alloc_zone_t *_iso_new_zone(size_t size, bool internal, int3
420420
LOG_AND_ABORT("Cannot allocate additional zones. I have already allocated %d zones", _root->zones_used);
421421
}
422422

423+
if(size > SMALL_SZ_MAX) {
424+
LOG("Request for new zone with %ld byte chunks should be handled by big alloc path", size);
425+
return NULL;
426+
}
427+
423428
/* In order for our bitmap to be a power of 2
424429
* the size we allocate also needs to be. We
425430
* want our bitmap to be a power of 2 because
@@ -430,11 +435,6 @@ INTERNAL_HIDDEN iso_alloc_zone_t *_iso_new_zone(size_t size, bool internal, int3
430435
size = next_pow2(size);
431436
}
432437

433-
if(size > SMALL_SZ_MAX) {
434-
LOG("Request for new zone with %ld byte chunks should be handled by big alloc path", size);
435-
return NULL;
436-
}
437-
438438
/* Minimum chunk size */
439439
if(size < SMALLEST_CHUNK_SZ) {
440440
size = SMALLEST_CHUNK_SZ;
@@ -1026,7 +1026,7 @@ INTERNAL_HIDDEN INLINE void populate_zone_cache(iso_alloc_zone_t *zone) {
10261026
INTERNAL_HIDDEN ASSUME_ALIGNED void *_iso_calloc(size_t nmemb, size_t size) {
10271027
unsigned int res;
10281028

1029-
if((is_pow2(size)) != true) {
1029+
if(size < SMALL_SZ_MAX && (is_pow2(size)) != true) {
10301030
size = next_pow2(size);
10311031
}
10321032

0 commit comments

Comments
 (0)