diff options
-rw-r--r-- | crypto/evp/digest.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/crypto/evp/digest.c b/crypto/evp/digest.c index 5da0e01039..33688f99e4 100644 --- a/crypto/evp/digest.c +++ b/crypto/evp/digest.c @@ -312,6 +312,13 @@ int EVP_MD_CTX_copy_ex(EVP_MD_CTX *out, const EVP_MD_CTX *in) EVP_MD_CTX_reset(out); memcpy(out, in, sizeof(*out)); + /* Null these variables, since they are getting fixed up + * properly below. Anything else may cause a memleak and/or + * double free if any of the memory allocations below fail + */ + out->md_data = NULL; + out->pctx = NULL; + if (in->md_data && out->digest->ctx_size) { if (tmp_buf) out->md_data = tmp_buf; |