Fix memory leak if setup fails.
authorDr. Stephen Henson <steve@openssl.org>
Sat, 1 Aug 2015 14:37:44 +0000 (15:37 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Wed, 12 Aug 2015 13:24:08 +0000 (14:24 +0100)
Reviewed-by: Matt Caswell <matt@openssl.org>
(cherry picked from commit 891eac4604b5f05413e59602fae1f11136f4719a)

Conflicts:
crypto/cms/cms_enc.c

crypto/cms/cms_enc.c

index 85ae928a496ff09633da8e9ff2870879ae357b80..b14b4b68b5c9508821fe5d2f9dbbf490924ea1a5 100644 (file)
@@ -195,7 +195,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
     ok = 1;
 
  err:
-    if (ec->key && !keep_key) {
+    if (ec->key && (!keep_key || !ok)) {
         OPENSSL_cleanse(ec->key, ec->keylen);
         OPENSSL_free(ec->key);
         ec->key = NULL;