From f38c6ceea7f4815d6fbbee45c4c37284b4a4fead Mon Sep 17 00:00:00 2001 From: qbix79 Date: Fri, 26 Jun 2009 17:04:46 +0000 Subject: [PATCH] Keep maxbins in sync with max threaded cache. Fixes memory corruption and out of bounds access git-svn-id: https://svn.eduke32.com/eduke32@1441 1a8010ca-5511-0410-912e-c29ae57300e0 --- polymer/eduke32/build/src/nedmalloc.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/polymer/eduke32/build/src/nedmalloc.c b/polymer/eduke32/build/src/nedmalloc.c index 40d6bbe12..df2580f2b 100644 --- a/polymer/eduke32/build/src/nedmalloc.c +++ b/polymer/eduke32/build/src/nedmalloc.c @@ -88,10 +88,22 @@ DEALINGS IN THE SOFTWARE. #endif #if 1 /* The number of cache entries for finer grained bins. This is (topbitpos(THREADCACHEMAX)-4)*2 */ +#if THREADCACHEMAX == 8192 #define THREADCACHEMAXBINS ((13-4)*2) +#elif THREADCACHEMAX == 65536 +#define THREADCACHEMAXBINS ((16-4)*2) +#else +#error undefined size +#endif #else /* The number of cache entries. This is (topbitpos(THREADCACHEMAX)-4) */ +#if THREADCACHEMAX == 8192 #define THREADCACHEMAXBINS (13-4) +#elif THREADCACHEMAX == 65536 +#define THREADCACHEMAXBINS (16-4) +#else +#error undefined size +#endif #endif /* Point at which the free space in a thread cache is garbage collected */ #ifndef THREADCACHEMAXFREESPACE