summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2012-06-10 02:15:05 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2012-06-10 02:15:05 +0200
commitcda8ef8cf1572e25d8667546745b80aab753e3d9 (patch)
tree0ae5fdfa611f1263b973645b5d3dbd95f8dd4659
parent4dd3adf7d4eccf2a5c7c16ee89610d9f0df81613 (diff)
downloadgnutls-cda8ef8cf1572e25d8667546745b80aab753e3d9.tar.gz
deinitialize extra certs if they are empty.
-rw-r--r--lib/x509/pkcs12.c26
1 files changed, 18 insertions, 8 deletions
diff --git a/lib/x509/pkcs12.c b/lib/x509/pkcs12.c
index a595488b32..47c10a15aa 100644
--- a/lib/x509/pkcs12.c
+++ b/lib/x509/pkcs12.c
@@ -1438,6 +1438,7 @@ gnutls_pkcs12_simple_parse (gnutls_pkcs12_t p12,
uint8_t cert_id[20];
uint8_t key_id[20];
int privkey_ok = 0;
+ unsigned int i;
*key = NULL;
@@ -1783,30 +1784,39 @@ done:
gnutls_x509_privkey_deinit(*key);
if (_extra_certs_len && _extra_certs != NULL)
{
- unsigned int i;
for (i = 0; i < _extra_certs_len; i++)
gnutls_x509_crt_deinit(_extra_certs[i]);
gnutls_free(_extra_certs);
}
if (_chain_len && chain != NULL)
{
- unsigned int i;
for (i = 0; i < _chain_len; i++)
gnutls_x509_crt_deinit(_chain[i]);
gnutls_free(_chain);
}
+
+ return ret;
}
- else
+
+ if (extra_certs && _extra_certs_len > 0)
+ {
+ *extra_certs = _extra_certs;
+ *extra_certs_len = _extra_certs_len;
+ }
+ else
{
if (extra_certs)
{
- *extra_certs = _extra_certs;
- *extra_certs_len = _extra_certs_len;
+ *extra_certs = NULL;
+ *extra_certs_len = 0;
}
-
- *chain = _chain;
- *chain_len = _chain_len;
+ for (i = 0; i < _extra_certs_len; i++)
+ gnutls_x509_crt_deinit(_extra_certs[i]);
+ gnutls_free(_extra_certs);
}
+
+ *chain = _chain;
+ *chain_len = _chain_len;
return ret;
}