Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/bsd/jemalloc/dist/src jemalloc: Avoid variable leng...



details:   https://anonhg.NetBSD.org/src/rev/a422753f6f3e
branches:  trunk
changeset: 1007351:a422753f6f3e
user:      kamil <kamil%NetBSD.org@localhost>
date:      Sat Feb 15 09:57:30 2020 +0000

description:
jemalloc: Avoid variable length array with length 0

Cherry-pick upstrem patch.

https://github.com/jemalloc/jemalloc/pull/1768

diffstat:

 external/bsd/jemalloc/dist/src/tcache.c |  6 ++++--
 1 files changed, 4 insertions(+), 2 deletions(-)

diffs (23 lines):

diff -r 07d3dad1e7de -r a422753f6f3e external/bsd/jemalloc/dist/src/tcache.c
--- a/external/bsd/jemalloc/dist/src/tcache.c   Sat Feb 15 09:26:07 2020 +0000
+++ b/external/bsd/jemalloc/dist/src/tcache.c   Sat Feb 15 09:57:30 2020 +0000
@@ -111,7 +111,8 @@
        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 @@
        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));



Home | Main Index | Thread Index | Old Index