From 3c4f16091673123e50172b73d2097387c411e1e2 Mon Sep 17 00:00:00 2001 From: jsg Date: Fri, 18 Apr 2014 03:28:12 +0000 Subject: [PATCH] fix another potential double free ok miod@ lteo@ jca@ --- lib/libcrypto/pkcs7/pk7_doit.c | 4 ++-- lib/libssl/src/crypto/pkcs7/pk7_doit.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/libcrypto/pkcs7/pk7_doit.c b/lib/libcrypto/pkcs7/pk7_doit.c index 396a863f3bb..fbe58cd45f0 100644 --- a/lib/libcrypto/pkcs7/pk7_doit.c +++ b/lib/libcrypto/pkcs7/pk7_doit.c @@ -928,6 +928,7 @@ int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si) if (EVP_DigestSignUpdate(&mctx,abuf,alen) <= 0) goto err; free(abuf); + abuf = NULL; if (EVP_DigestSignFinal(&mctx, NULL, &siglen) <= 0) goto err; abuf = malloc(siglen); @@ -950,8 +951,7 @@ int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si) return 1; err: - if (abuf) - free(abuf); + free(abuf); EVP_MD_CTX_cleanup(&mctx); return 0; diff --git a/lib/libssl/src/crypto/pkcs7/pk7_doit.c b/lib/libssl/src/crypto/pkcs7/pk7_doit.c index 396a863f3bb..fbe58cd45f0 100644 --- a/lib/libssl/src/crypto/pkcs7/pk7_doit.c +++ b/lib/libssl/src/crypto/pkcs7/pk7_doit.c @@ -928,6 +928,7 @@ int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si) if (EVP_DigestSignUpdate(&mctx,abuf,alen) <= 0) goto err; free(abuf); + abuf = NULL; if (EVP_DigestSignFinal(&mctx, NULL, &siglen) <= 0) goto err; abuf = malloc(siglen); @@ -950,8 +951,7 @@ int PKCS7_SIGNER_INFO_sign(PKCS7_SIGNER_INFO *si) return 1; err: - if (abuf) - free(abuf); + free(abuf); EVP_MD_CTX_cleanup(&mctx); return 0; -- 2.20.1