summaryrefslogtreecommitdiffstats
path: root/crypto/pkcs12/p12_init.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2004-12-05 01:03:15 +0000
committerDr. Stephen Henson <steve@openssl.org>2004-12-05 01:03:15 +0000
commita0e7c8eede26b29b09057f48b8e51f46f8811ddd (patch)
tree2b50575b4e9e608b61cb74246915625bd99b85d8 /crypto/pkcs12/p12_init.c
parenta8e00b17ce840c58787e45411fa2ac4d6b1fb10c (diff)
Add lots of checks for memory allocation failure, error codes to indicate
failure and freeing up memory if a failure occurs. PR:620
Diffstat (limited to 'crypto/pkcs12/p12_init.c')
-rw-r--r--crypto/pkcs12/p12_init.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/crypto/pkcs12/p12_init.c b/crypto/pkcs12/p12_init.c
index eb837a78cf..5276b12669 100644
--- a/crypto/pkcs12/p12_init.c
+++ b/crypto/pkcs12/p12_init.c
@@ -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;
}