From: jsg Date: Fri, 18 Apr 2014 03:28:12 +0000 (+0000) Subject: fix another potential double free X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=3c4f16091673123e50172b73d2097387c411e1e2;p=openbsd fix another potential double free ok miod@ lteo@ jca@ --- 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;