From ead04d2e0e736be5a75b296b93c2641a6087e60e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Love=20H=C3=B6rnquist=20=C3=85strand?= Date: Mon, 16 Oct 2006 09:50:49 +0000 Subject: [PATCH] Remember to release certs. git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@18472 ec53bebd-3082-4978-b11e-865c3cabbd6b --- lib/hx509/ks_p11.c | 18 ++++++++++-------- lib/hx509/ks_p12.c | 6 +++++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/hx509/ks_p11.c b/lib/hx509/ks_p11.c index 3d46923ff..30f12475a 100644 --- a/lib/hx509/ks_p11.c +++ b/lib/hx509/ks_p11.c @@ -740,12 +740,9 @@ collect_cert(struct p11_module *p, struct p11_slot *slot, } ret = _hx509_collector_certs_add(ctx->context, ctx->c, cert); - if (ret) { - hx509_cert_free(cert); - return ret; - } + hx509_cert_free(cert); - return 0; + return ret; } @@ -967,8 +964,6 @@ p11_release_module(struct p11_module *p) ; } - if (p->slot[i].certs) - hx509_certs_free(&p->slot[i].certs); if (p->slot[i].name) free(p->slot[i].name); if (p->slot[i].pin) { @@ -1002,7 +997,14 @@ p11_release_module(struct p11_module *p) static int p11_free(hx509_certs certs, void *data) { - p11_release_module((struct p11_module *)data); + struct p11_module *p = data; + int i; + + for (i = 0; i < p->num_slots; i++) { + if (p->slot[i].certs) + hx509_certs_free(&p->slot[i].certs); + } + p11_release_module(p); return 0; } diff --git a/lib/hx509/ks_p12.c b/lib/hx509/ks_p12.c index 9a099e4b5..052c7065c 100644 --- a/lib/hx509/ks_p12.c +++ b/lib/hx509/ks_p12.c @@ -164,9 +164,13 @@ certBag_parser(hx509_context context, const heim_oid *oid = (*(oids[i]))(); attr = find_attribute(attrs, oid); if (attr) - _hx509_set_cert_attribute(context, cert, oid, &attr->attrValues); + _hx509_set_cert_attribute(context, cert, oid, + &attr->attrValues); } } + + hx509_cert_free(cert); + return 0; }