From 177f1a403663d24fcb185e92f99c0d045483851e Mon Sep 17 00:00:00 2001 From: miod Date: Thu, 17 Apr 2014 20:57:05 +0000 Subject: [PATCH] malloc + memset 0 -> calloc (not that it matters much as this is in disabled code, for we don't build with zlib support) --- lib/libcrypto/comp/c_zlib.c | 24 ++---------------------- lib/libssl/src/crypto/comp/c_zlib.c | 24 ++---------------------- 2 files changed, 4 insertions(+), 44 deletions(-) diff --git a/lib/libcrypto/comp/c_zlib.c b/lib/libcrypto/comp/c_zlib.c index 2ced7c10cc3..e50b6eb4a38 100644 --- a/lib/libcrypto/comp/c_zlib.c +++ b/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/lib/libssl/src/crypto/comp/c_zlib.c b/lib/libssl/src/crypto/comp/c_zlib.c index 2ced7c10cc3..e50b6eb4a38 100644 --- a/lib/libssl/src/crypto/comp/c_zlib.c +++ b/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 -- 2.20.1