Check PKCS7 structures in PKCS#12 files are of type data.
[openssl.git] / crypto / pkcs12 / p12_init.c
index eb837a7..6bdc132 100644 (file)
@@ -62,7 +62,7 @@
 
 /* Initialise a PKCS12 structure to take data */
 
-PKCS12 *PKCS12_init (int mode)
+PKCS12 *PKCS12_init(int mode)
 {
        PKCS12 *pkcs12;
        if (!(pkcs12 = PKCS12_new())) {
@@ -76,15 +76,17 @@ PKCS12 *PKCS12_init (int mode)
                        if (!(pkcs12->authsafes->d.data =
                                 M_ASN1_OCTET_STRING_new())) {
                        PKCS12err(PKCS12_F_PKCS12_INIT,ERR_R_MALLOC_FAILURE);
-                       return NULL;
+                       goto err;
                }
                break;
                default:
-                       PKCS12err(PKCS12_F_PKCS12_INIT,PKCS12_R_UNSUPPORTED_PKCS12_MODE);
-                       PKCS12_free(pkcs12);
-                       return NULL;
-               break;
+                       PKCS12err(PKCS12_F_PKCS12_INIT,
+                               PKCS12_R_UNSUPPORTED_PKCS12_MODE);
+                       goto err;
        }
                
        return pkcs12;
+err:
+       if (pkcs12 != NULL) PKCS12_free(pkcs12);
+       return NULL;
 }