diff options
author | Rich Salz <rsalz@akamai.com> | 2015-08-25 13:25:58 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2015-09-02 22:05:37 -0400 |
commit | b51bce942023325e727ca4225252d06c49d8f2b7 (patch) | |
tree | 59bbdee7553f9132a86aca17752a9a358a6355e2 /crypto/sec_mem.c | |
parent | 66e87a9f0990198079bf4d2b3ce87581ad5b6b10 (diff) |
Add and use OPENSSL_zalloc
There are many places (nearly 50) where we malloc and then memset.
Add an OPENSSL_zalloc routine to encapsulate that.
(Missed one conversion; thanks Richard)
Also fixes GH328
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/sec_mem.c')
-rw-r--r-- | crypto/sec_mem.c | 9 |
1 files changed, 3 insertions, 6 deletions
diff --git a/crypto/sec_mem.c b/crypto/sec_mem.c index a630cbc82e..fbed8b49fc 100644 --- a/crypto/sec_mem.c +++ b/crypto/sec_mem.c @@ -314,23 +314,20 @@ static int sh_init(size_t size, int minsize) for (i = sh.bittable_size; i; i >>= 1) sh.freelist_size++; - sh.freelist = OPENSSL_malloc(sh.freelist_size * sizeof (char *)); + sh.freelist = OPENSSL_zalloc(sh.freelist_size * sizeof (char *)); OPENSSL_assert(sh.freelist != NULL); if (sh.freelist == NULL) goto err; - memset(sh.freelist, 0, sh.freelist_size * sizeof (char *)); - sh.bittable = OPENSSL_malloc(sh.bittable_size >> 3); + sh.bittable = OPENSSL_zalloc(sh.bittable_size >> 3); OPENSSL_assert(sh.bittable != NULL); if (sh.bittable == NULL) goto err; - memset(sh.bittable, 0, sh.bittable_size >> 3); - sh.bitmalloc = OPENSSL_malloc(sh.bittable_size >> 3); + sh.bitmalloc = OPENSSL_zalloc(sh.bittable_size >> 3); OPENSSL_assert(sh.bitmalloc != NULL); if (sh.bitmalloc == NULL) goto err; - memset(sh.bitmalloc, 0, sh.bittable_size >> 3); /* Allocate space for heap, and two extra pages as guards */ #ifdef _SC_PAGE_SIZE |