jemalloc: Avoid variable length array with length 0
Cherry-pick upstrem patch. https://github.com/jemalloc/jemalloc/pull/1768
This commit is contained in:
parent
9366ffe370
commit
93a18a197a
6
external/bsd/jemalloc/dist/src/tcache.c
vendored
6
external/bsd/jemalloc/dist/src/tcache.c
vendored
@ -111,7 +111,8 @@ tcache_bin_flush_small(tsd_t *tsd, tcache_t *tcache, cache_bin_t *tbin,
|
||||
arena_t *arena = tcache->arena;
|
||||
assert(arena != NULL);
|
||||
unsigned nflush = tbin->ncached - rem;
|
||||
VARIABLE_ARRAY(extent_t *, item_extent, nflush);
|
||||
/* Variable length array must have > 0 length. */
|
||||
VARIABLE_ARRAY(extent_t *, item_extent, nflush + + 1);
|
||||
/* Look up extent once per item. */
|
||||
for (unsigned i = 0 ; i < nflush; i++) {
|
||||
item_extent[i] = iealloc(tsd_tsdn(tsd), *(tbin->avail - 1 - i));
|
||||
@ -196,7 +197,8 @@ tcache_bin_flush_large(tsd_t *tsd, cache_bin_t *tbin, szind_t binind,
|
||||
arena_t *arena = tcache->arena;
|
||||
assert(arena != NULL);
|
||||
unsigned nflush = tbin->ncached - rem;
|
||||
VARIABLE_ARRAY(extent_t *, item_extent, nflush);
|
||||
/* Variable length array must have > 0 length. */
|
||||
VARIABLE_ARRAY(extent_t *, item_extent, nflush + 1);
|
||||
/* Look up extent once per item. */
|
||||
for (unsigned i = 0 ; i < nflush; i++) {
|
||||
item_extent[i] = iealloc(tsd_tsdn(tsd), *(tbin->avail - 1 - i));
|
||||
|
Loading…
Reference in New Issue
Block a user