From 6800e69ce3db198d08e1e509efdb706f4d2b4cf0 Mon Sep 17 00:00:00 2001 From: miod <> Date: Thu, 17 Apr 2014 20:57:05 +0000 Subject: malloc + memset 0 -> calloc (not that it matters much as this is in disabled code, for we don't build with zlib support) --- src/lib/libcrypto/comp/c_zlib.c | 24 ++---------------------- src/lib/libssl/src/crypto/comp/c_zlib.c | 24 ++---------------------- 2 files changed, 4 insertions(+), 44 deletions(-) (limited to 'src/lib') diff --git a/src/lib/libcrypto/comp/c_zlib.c b/src/lib/libcrypto/comp/c_zlib.c index 2ced7c10cc..e50b6eb4a3 100644 --- a/src/lib/libcrypto/comp/c_zlib.c +++ b/src/lib/libcrypto/comp/c_zlib.c @@ -35,15 +35,9 @@ static int zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out, /* memory allocations functions for zlib intialization */ static void* zlib_zalloc(void* opaque, unsigned int no, unsigned int size) { - void *p; - - p=malloc(no*size); - if (p) - memset(p, 0, no*size); - return p; + return calloc(no, size); } - static void zlib_zfree(void* opaque, void* address) { free(address); @@ -81,16 +75,6 @@ static COMP_METHOD zlib_stateful_method={ NULL, }; -/* - * When OpenSSL is built on Windows, we do not want to require that - * the ZLIB.DLL be available in order for the OpenSSL DLLs to - * work. Therefore, all ZLIB routines are loaded at run time - * and we do not link to a .LIB file when ZLIB_SHARED is set. - */ -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) -# include -#endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */ - #ifdef ZLIB_SHARED #include @@ -173,7 +157,7 @@ static int zlib_stateful_init(COMP_CTX *ctx) CRYPTO_set_ex_data(&ctx->ex_data,zlib_stateful_ex_idx,state); return 1; err: - if (state) free(state); + free(state); return 0; } @@ -345,11 +329,7 @@ COMP_METHOD *COMP_zlib(void) #ifdef ZLIB_SHARED if (!zlib_loaded) { -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) - zlib_dso = DSO_load(NULL, "ZLIB1", NULL, 0); -#else zlib_dso = DSO_load(NULL, "z", NULL, 0); -#endif if (zlib_dso != NULL) { p_compress diff --git a/src/lib/libssl/src/crypto/comp/c_zlib.c b/src/lib/libssl/src/crypto/comp/c_zlib.c index 2ced7c10cc..e50b6eb4a3 100644 --- a/src/lib/libssl/src/crypto/comp/c_zlib.c +++ b/src/lib/libssl/src/crypto/comp/c_zlib.c @@ -35,15 +35,9 @@ static int zlib_stateful_expand_block(COMP_CTX *ctx, unsigned char *out, /* memory allocations functions for zlib intialization */ static void* zlib_zalloc(void* opaque, unsigned int no, unsigned int size) { - void *p; - - p=malloc(no*size); - if (p) - memset(p, 0, no*size); - return p; + return calloc(no, size); } - static void zlib_zfree(void* opaque, void* address) { free(address); @@ -81,16 +75,6 @@ static COMP_METHOD zlib_stateful_method={ NULL, }; -/* - * When OpenSSL is built on Windows, we do not want to require that - * the ZLIB.DLL be available in order for the OpenSSL DLLs to - * work. Therefore, all ZLIB routines are loaded at run time - * and we do not link to a .LIB file when ZLIB_SHARED is set. - */ -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) -# include -#endif /* !(OPENSSL_SYS_WINDOWS || OPENSSL_SYS_WIN32) */ - #ifdef ZLIB_SHARED #include @@ -173,7 +157,7 @@ static int zlib_stateful_init(COMP_CTX *ctx) CRYPTO_set_ex_data(&ctx->ex_data,zlib_stateful_ex_idx,state); return 1; err: - if (state) free(state); + free(state); return 0; } @@ -345,11 +329,7 @@ COMP_METHOD *COMP_zlib(void) #ifdef ZLIB_SHARED if (!zlib_loaded) { -#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_WIN32) - zlib_dso = DSO_load(NULL, "ZLIB1", NULL, 0); -#else zlib_dso = DSO_load(NULL, "z", NULL, 0); -#endif if (zlib_dso != NULL) { p_compress -- cgit v1.2.3-55-g6feb