Reviewed-by: Andy Polyakov <appro@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/4146)
{
STACK_OF(X509) *ocerts = NULL;
X509 *x = NULL;
+
+ if (pkey)
+ *pkey = NULL;
+ if (cert)
+ *cert = NULL;
+
/* Check for NULL PKCS12 structure */
if (!p12) {
return 0;
}
- if (pkey)
- *pkey = NULL;
- if (cert)
- *cert = NULL;
-
/* Check the mac */
/*
if (!ocerts) {
PKCS12err(PKCS12_F_PKCS12_PARSE, ERR_R_MALLOC_FAILURE);
- return 0;
+ goto err;
}
if (!parse_pk12(p12, pass, -1, pkey, ocerts)) {
err:
- if (pkey && *pkey)
+ if (pkey) {
EVP_PKEY_free(*pkey);
- if (cert && *cert)
+ *pkey = NULL;
+ }
+ if (cert) {
X509_free(*cert);
+ *cert = NULL;
+ }
if (x)
X509_free(x);
if (ocerts)