summaryrefslogtreecommitdiffstats
path: root/crypto/comp
diff options
context:
space:
mode:
authorRich Salz <rsalz@akamai.com>2015-08-25 19:25:58 +0200
committerRich Salz <rsalz@openssl.org>2015-09-03 04:05:37 +0200
commitb51bce942023325e727ca4225252d06c49d8f2b7 (patch)
tree59bbdee7553f9132a86aca17752a9a358a6355e2 /crypto/comp
parentmake update (diff)
downloadopenssl-b51bce942023325e727ca4225252d06c49d8f2b7.tar.xz
openssl-b51bce942023325e727ca4225252d06c49d8f2b7.zip
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/comp')
-rw-r--r--crypto/comp/c_zlib.c4
-rw-r--r--crypto/comp/comp_lib.c3
2 files changed, 2 insertions, 5 deletions
diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c
index f0fc0aff9e..474751192a 100644
--- a/crypto/comp/c_zlib.c
+++ b/crypto/comp/c_zlib.c
@@ -91,9 +91,7 @@ static void *zlib_zalloc(void *opaque, unsigned int no, unsigned int size)
{
void *p;
- p = OPENSSL_malloc(no * size);
- if (p)
- memset(p, 0, no * size);
+ p = OPENSSL_zalloc(no * size);
return p;
}
diff --git a/crypto/comp/comp_lib.c b/crypto/comp/comp_lib.c
index aa82376cdd..83fea93cb8 100644
--- a/crypto/comp/comp_lib.c
+++ b/crypto/comp/comp_lib.c
@@ -63,9 +63,8 @@ COMP_CTX *COMP_CTX_new(COMP_METHOD *meth)
{
COMP_CTX *ret;
- if ((ret = OPENSSL_malloc(sizeof(*ret))) == NULL)
+ if ((ret = OPENSSL_zalloc(sizeof(*ret))) == NULL)
return (NULL);
- memset(ret, 0, sizeof(*ret));
ret->meth = meth;
if ((ret->meth->init != NULL) && !ret->meth->init(ret)) {
OPENSSL_free(ret);