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 12:54:56 +0000 (13:54 +0100)
Reviewed-by: Matt Caswell <matt@openssl.org>
crypto/cms/cms_enc.c

index f9556ac..16b4225 100644 (file)
@@ -194,7 +194,7 @@ BIO *cms_EncryptedContent_init_bio(CMS_EncryptedContentInfo *ec)
     ok = 1;
 
  err:
-    if (!keep_key) {
+    if (!keep_key || !ok) {
         OPENSSL_clear_free(ec->key, ec->keylen);
         ec->key = NULL;
     }