aboutsummaryrefslogtreecommitdiffstats
path: root/smime
diff options
context:
space:
mode:
Diffstat (limited to 'smime')
-rw-r--r--smime/gui/certificate-manager.c6
-rw-r--r--smime/lib/e-cert-db.c9
-rw-r--r--smime/lib/e-cert.c17
3 files changed, 26 insertions, 6 deletions
diff --git a/smime/gui/certificate-manager.c b/smime/gui/certificate-manager.c
index f3a175c711..505ffaf30f 100644
--- a/smime/gui/certificate-manager.c
+++ b/smime/gui/certificate-manager.c
@@ -959,14 +959,18 @@ load_certs (CertificateManagerData *cfm,
for (node = CERT_LIST_HEAD(certList);
!CERT_LIST_END(node, certList);
node = CERT_LIST_NEXT(node)) {
- ECert *cert = e_cert_new ((CERTCertificate*)node->cert);
+ ECert *cert = e_cert_new (CERT_DupCertificate ((CERTCertificate*)node->cert));
ECertType ct = e_cert_get_cert_type (cert);
/* show everything else in a contact tab */
if (ct == type || (type == E_CERT_CONTACT && ct != E_CERT_CA && ct != E_CERT_USER)) {
add_cert (cfm, cert);
+ } else {
+ g_object_unref (cert);
}
}
+
+ CERT_DestroyCertList (certList);
}
static void
diff --git a/smime/lib/e-cert-db.c b/smime/lib/e-cert-db.c
index fc976bffba..c21d071a96 100644
--- a/smime/lib/e-cert-db.c
+++ b/smime/lib/e-cert-db.c
@@ -513,18 +513,21 @@ e_cert_db_find_cert_by_email_address (ECertDB *certdb,
if (SECSuccess != CERT_FilterCertListByUsage(certlist, certUsageEmailRecipient, PR_FALSE)) {
/* XXX gerror */
CERT_DestroyCertificate(any_cert);
- /* XXX free certlist? */
+ CERT_DestroyCertList (certlist);
return NULL;
}
if (CERT_LIST_END(CERT_LIST_HEAD(certlist), certlist)) {
/* XXX gerror */
CERT_DestroyCertificate(any_cert);
- /* XXX free certlist? */
+ CERT_DestroyCertList (certlist);
return NULL;
}
- cert = e_cert_new (CERT_LIST_HEAD(certlist)->cert);
+ cert = e_cert_new (CERT_DupCertificate (CERT_LIST_HEAD(certlist)->cert));
+
+ CERT_DestroyCertList (certlist);
+ CERT_DestroyCertificate (any_cert);
return cert;
}
diff --git a/smime/lib/e-cert.c b/smime/lib/e-cert.c
index 2591678cec..db4104859e 100644
--- a/smime/lib/e-cert.c
+++ b/smime/lib/e-cert.c
@@ -140,6 +140,11 @@ e_cert_dispose (GObject *object)
}
}
+ if (ec->priv->cert) {
+ CERT_DestroyCertificate (ec->priv->cert);
+ ec->priv->cert = NULL;
+ }
+
g_free (ec->priv);
ec->priv = NULL;
@@ -257,6 +262,7 @@ e_cert_new (CERTCertificate *cert)
{
ECert *ecert = E_CERT (g_object_new (E_TYPE_CERT, NULL));
+ /* ECert owns a reference to the 'cert', which will be freed on ECert finalize */
ecert->priv->cert = cert;
e_cert_populate (ecert);
@@ -468,6 +474,8 @@ e_cert_get_chain (ECert *ecert)
next_cert = CERT_FindCertIssuer (cert, PR_Now(), certUsageSSLClient);
if (!next_cert)
break;
+
+ /* next_cert has a reference already */
ecert = e_cert_new (next_cert);
}
@@ -477,14 +485,19 @@ e_cert_get_chain (ECert *ecert)
ECert *
e_cert_get_ca_cert(ECert *ecert)
{
- CERTCertificate *cert, *next = e_cert_get_internal_cert(ecert);
+ CERTCertificate *cert, *next = e_cert_get_internal_cert(ecert), *internal;
+ cert = next;
+ internal = cert;
do {
+ if (cert != next && cert != internal)
+ CERT_DestroyCertificate (cert);
+
cert = next;
next = CERT_FindCertIssuer (cert, PR_Now(), certUsageAnyCA);
} while (next && next != cert);
- if (cert == e_cert_get_internal_cert(ecert))
+ if (cert == internal)
return g_object_ref(ecert);
else
return e_cert_new(cert);