Module Name: src
Committed By: kamil
Date: Sat Feb 15 09:57:30 UTC 2020
Modified Files:
src/external/bsd/jemalloc/dist/src: tcache.c
Log Message:
jemalloc: Avoid variable length array with length 0
Cherry-pick upstrem patch.
https://github.com/jemalloc/jemalloc/pull/1768
To generate a diff of this commit:
cvs rdiff -u -r1.1.1.1 -r1.2 src/external/bsd/jemalloc/dist/src/tcache.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/external/bsd/jemalloc/dist/src/tcache.c
diff -u src/external/bsd/jemalloc/dist/src/tcache.c:1.1.1.1 src/external/bsd/jemalloc/dist/src/tcache.c:1.2
--- src/external/bsd/jemalloc/dist/src/tcache.c:1.1.1.1 Mon Mar 4 17:10:23 2019
+++ src/external/bsd/jemalloc/dist/src/tcache.c Sat Feb 15 09:57:30 2020
@@ -111,7 +111,8 @@ tcache_bin_flush_small(tsd_t *tsd, tcach
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
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));