pki: Properly clean up if output format for --pkcs12 is wrong
authorTobias Brunner <tobias@strongswan.org>
Fri, 19 Dec 2014 15:30:10 +0000 (16:30 +0100)
committerTobias Brunner <tobias@strongswan.org>
Fri, 19 Dec 2014 15:30:10 +0000 (16:30 +0100)
src/pki/commands/pkcs12.c

index fe92fa8..67f0268 100644 (file)
@@ -75,6 +75,7 @@ static int export(pkcs12_t *pkcs12, int index, char *outform)
                        form = CERT_ASN1_DER;
                        if (outform && !get_form(outform, &form, CRED_CERTIFICATE))
                        {
+                               enumerator->destroy(enumerator);
                                return command_usage("invalid output format");
                        }
                        if (cert->get_encoding(cert, form, &encoding))
@@ -103,6 +104,7 @@ static int export(pkcs12_t *pkcs12, int index, char *outform)
                        form = PRIVKEY_ASN1_DER;
                        if (outform && !get_form(outform, &form, CRED_PRIVATE_KEY))
                        {
+                               enumerator->destroy(enumerator);
                                return command_usage("invalid output format");
                        }
                        if (key->get_encoding(key, form, &encoding))