Avoid variable length array with length 0.

This commit is contained in:
Qi Wang 2020-02-13 20:04:22 -08:00 committed by Qi Wang
parent 68e8ddcaff
commit 0f686e82a3

View File

@ -149,7 +149,8 @@ tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
arena_t *arena = tcache->arena; arena_t *arena = tcache->arena;
assert(arena != NULL); assert(arena != NULL);
unsigned nflush = ncached - rem; unsigned nflush = ncached - rem;
VARIABLE_ARRAY(edata_t *, item_edata, nflush); /* Variable length array must have > 0 length. */
VARIABLE_ARRAY(edata_t *, item_edata, nflush + 1);
void **bottom_item = cache_bin_bottom_item_get(tbin, binind); void **bottom_item = cache_bin_bottom_item_get(tbin, binind);
tsdn_t *tsdn = tsd_tsdn(tsd); tsdn_t *tsdn = tsd_tsdn(tsd);
@ -250,7 +251,8 @@ tcache_bin_flush_large(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin, szind_t
arena_t *tcache_arena = tcache->arena; arena_t *tcache_arena = tcache->arena;
assert(tcache_arena != NULL); assert(tcache_arena != NULL);
unsigned nflush = ncached - rem; unsigned nflush = ncached - rem;
VARIABLE_ARRAY(edata_t *, item_edata, nflush); /* Variable length array must have > 0 length. */
VARIABLE_ARRAY(edata_t *, item_edata, nflush + 1);
void **bottom_item = cache_bin_bottom_item_get(tbin, binind); void **bottom_item = cache_bin_bottom_item_get(tbin, binind);
#ifndef JEMALLOC_EXTRA_SIZE_CHECK #ifndef JEMALLOC_EXTRA_SIZE_CHECK