Fix memory leak.
authorDr. Stephen Henson <steve@openssl.org>
Thu, 21 May 2015 00:15:51 +0000 (01:15 +0100)
committerDr. Stephen Henson <steve@openssl.org>
Tue, 26 May 2015 12:09:25 +0000 (13:09 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
crypto/pkcs12/p12_decr.c

index f19830cf730c5983ac54fec9bbb5775e65a514ba..8996b9ed8470661a6d02d5c47d4182a941a7864d 100644 (file)
@@ -75,7 +75,7 @@ unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,
                                 int passlen, unsigned char *in, int inlen,
                                 unsigned char **data, int *datalen, int en_de)
 {
-    unsigned char *out;
+    unsigned char *out = NULL;
     int outlen, i;
     EVP_CIPHER_CTX ctx;
 
@@ -85,7 +85,7 @@ unsigned char *PKCS12_pbe_crypt(X509_ALGOR *algor, const char *pass,
                             algor->parameter, &ctx, en_de)) {
         PKCS12err(PKCS12_F_PKCS12_PBE_CRYPT,
                   PKCS12_R_PKCS12_ALGOR_CIPHERINIT_ERROR);
-        return NULL;
+        goto err;
     }
 
     if ((out = OPENSSL_malloc(inlen + EVP_CIPHER_CTX_block_size(&ctx)))