summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeoff Thorpe <geoff@openssl.org>2001-09-01 18:37:17 +0000
committerGeoff Thorpe <geoff@openssl.org>2001-09-01 18:37:17 +0000
commite19ea55783bc3e1af5bc6a51775ed41b638aab10 (patch)
tree8285c0f3cf4d051d091ac11b3c6ce8b0bc3b43d3
parent8716dbea40e80bc495624d37fe883a57103d45f0 (diff)
Only OPENSSL_free() non-NULL pointers.
-rw-r--r--crypto/evp/digest.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c
index 5c5b118486..1457a00118 100644
--- a/crypto/evp/digest.c
+++ b/crypto/evp/digest.c
@@ -84,7 +84,8 @@ int EVP_DigestInit(EVP_MD_CTX *ctx, const EVP_MD *type)
{
if(ctx->digest != type)
{
- OPENSSL_free(ctx->md_data);
+ if(ctx->md_data != NULL)
+ OPENSSL_free(ctx->md_data);
ctx->digest=type;
#ifdef CRYPTO_MDEBUG
ctx->md_data=CRYPTO_malloc(type->ctx_size,file,line);
@@ -155,9 +156,10 @@ int EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx)
* because sometimes only copies of the context are ever finalised.
*/
if(ctx->md_data)
- memset(ctx->md_data,0,ctx->digest->ctx_size);
-
- OPENSSL_free(ctx->md_data);
+ {
+ memset(ctx->md_data,0,ctx->digest->ctx_size);
+ OPENSSL_free(ctx->md_data);
+ }
memset(ctx,'\0',sizeof *ctx);
return 1;