diff options
author | Hugo van der Sanden <hv@crypt.org> | 2002-07-19 22:47:57 +0000 |
---|---|---|
committer | chip <chip@pobox.com> | 2002-07-19 22:47:57 +0000 |
commit | c3d48d4eb69b179fda4abfde9f3f9d4e70175253 (patch) | |
tree | 760837873123fb4dc3c9c2a8259ec9113f0ebdcb | |
parent | c15618675dfa13dd673bd6d471ddf2288512c9b4 (diff) | |
download | perl-c3d48d4eb69b179fda4abfde9f3f9d4e70175253.tar.gz |
ensure that hashes never attempt to malloc with a negative size
Subject: Re: [ID 20000421.002] Math::BigInt out of memory?
p4raw-id: //depot/maint-5.005/perl@17647
-rw-r--r-- | hv.c | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -25,7 +25,10 @@ static void more_he _((void)); # define ARRAY_ALLOC_BYTES(size) ( (size)*sizeof(HE*) ) #else # define MALLOC_OVERHEAD 16 -# define ARRAY_ALLOC_BYTES(size) ( (size)*sizeof(HE*)*2 - MALLOC_OVERHEAD ) +# define ARRAY_ALLOC_BYTES(size) \ + (((size) < 64) \ + ? (size) * sizeof(HE*) \ + : (size) * sizeof(HE*) * 2 - MALLOC_OVERHEAD) #endif STATIC HE* |