diff options
author | Dr. Stephen Henson <steve@openssl.org> | 2004-11-23 22:22:21 +0100 |
---|---|---|
committer | Dr. Stephen Henson <steve@openssl.org> | 2004-11-23 22:22:21 +0100 |
commit | 16df5f066a19d0f2275ba8a9d5459d2b56ba085f (patch) | |
tree | 853f56d610c877cbd751a0bf9a627c4dcd22bb51 /apps | |
parent | linux-x86_64 didn't link after EM64T RC4 tune-up... (diff) | |
download | openssl-16df5f066a19d0f2275ba8a9d5459d2b56ba085f.tar.xz openssl-16df5f066a19d0f2275ba8a9d5459d2b56ba085f.zip |
Fix memory leak.
Diffstat (limited to 'apps')
-rw-r--r-- | apps/pkcs12.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/apps/pkcs12.c b/apps/pkcs12.c index dd0d29bfaa..e08d75b265 100644 --- a/apps/pkcs12.c +++ b/apps/pkcs12.c @@ -665,9 +665,10 @@ int MAIN(int argc, char **argv) int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass, int passlen, int options, char *pempass) { - STACK_OF(PKCS7) *asafes; + STACK_OF(PKCS7) *asafes = NULL; STACK_OF(PKCS12_SAFEBAG) *bags; int i, bagnid; + int ret = 0; PKCS7 *p7; if (!( asafes = PKCS12_unpack_authsafes(p12))) return 0; @@ -685,16 +686,22 @@ int dump_certs_keys_p12 (BIO *out, PKCS12 *p12, char *pass, } bags = PKCS12_unpack_p7encdata(p7, pass, passlen); } else continue; - if (!bags) return 0; + if (!bags) goto err; if (!dump_certs_pkeys_bags (out, bags, pass, passlen, options, pempass)) { sk_PKCS12_SAFEBAG_pop_free (bags, PKCS12_SAFEBAG_free); - return 0; + goto err; } sk_PKCS12_SAFEBAG_pop_free (bags, PKCS12_SAFEBAG_free); + bags = NULL; } - sk_PKCS7_pop_free (asafes, PKCS7_free); - return 1; + ret = 1; + + err: + + if (asafes) + sk_PKCS7_pop_free (asafes, PKCS7_free); + return ret; } int dump_certs_pkeys_bags (BIO *out, STACK_OF(PKCS12_SAFEBAG) *bags, |