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 f9556acc2e632228c073a31e964b98636d29b5d8..16b42251d19224253b73e8c033e4b22e11a5d420 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;
     }