summaryrefslogtreecommitdiffstats
path: root/ssl/ssl_cert.c
diff options
context:
space:
mode:
authorDr. Stephen Henson <steve@openssl.org>2012-04-06 12:02:43 +0000
committerDr. Stephen Henson <steve@openssl.org>2012-04-06 12:02:43 +0000
commit0ac89e8f5472dbca4c1dd2cfbbe13968c31c505d (patch)
treefa0529599b10a10e081b82aaa43e6bcb6211e013 /ssl/ssl_cert.c
parent7e65b21a245e64f4e0984eddaaff4137e7bf616f (diff)
Backport: code tidy (from HEAD)
Diffstat (limited to 'ssl/ssl_cert.c')
-rw-r--r--ssl/ssl_cert.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/ssl/ssl_cert.c b/ssl/ssl_cert.c
index 16c060b711..571839c9b4 100644
--- a/ssl/ssl_cert.c
+++ b/ssl/ssl_cert.c
@@ -274,17 +274,18 @@ CERT *ssl_cert_dup(CERT *cert)
for (i = 0; i < SSL_PKEY_NUM; i++)
{
- if (cert->pkeys[i].x509 != NULL)
+ CERT_PKEY *cpk = cert->pkeys + i;
+ CERT_PKEY *rpk = ret->pkeys + i;
+ if (cpk->x509 != NULL)
{
- ret->pkeys[i].x509 = cert->pkeys[i].x509;
- CRYPTO_add(&ret->pkeys[i].x509->references, 1,
- CRYPTO_LOCK_X509);
+ rpk->x509 = cpk->x509;
+ CRYPTO_add(&rpk->x509->references, 1, CRYPTO_LOCK_X509);
}
- if (cert->pkeys[i].privatekey != NULL)
+ if (cpk->privatekey != NULL)
{
- ret->pkeys[i].privatekey = cert->pkeys[i].privatekey;
- CRYPTO_add(&ret->pkeys[i].privatekey->references, 1,
+ rpk->privatekey = cpk->privatekey;
+ CRYPTO_add(&cpk->privatekey->references, 1,
CRYPTO_LOCK_EVP_PKEY);
switch(i)
@@ -347,12 +348,14 @@ err:
for (i = 0; i < SSL_PKEY_NUM; i++)
{
- if (ret->pkeys[i].x509 != NULL)
- X509_free(ret->pkeys[i].x509);
- if (ret->pkeys[i].privatekey != NULL)
- EVP_PKEY_free(ret->pkeys[i].privatekey);
+ CERT_PKEY *rpk = ret->pkeys + i;
+ if (rpk->x509 != NULL)
+ X509_free(rpk->x509);
+ if (rpk->privatekey != NULL)
+ EVP_PKEY_free(rpk->privatekey);
}
+
return NULL;
}
@@ -389,10 +392,11 @@ void ssl_cert_free(CERT *c)
for (i=0; i<SSL_PKEY_NUM; i++)
{
- if (c->pkeys[i].x509 != NULL)
- X509_free(c->pkeys[i].x509);
- if (c->pkeys[i].privatekey != NULL)
- EVP_PKEY_free(c->pkeys[i].privatekey);
+ CERT_PKEY *cpk = c->pkeys + i;
+ if (cpk->x509 != NULL)
+ X509_free(cpk->x509);
+ if (cpk->privatekey != NULL)
+ EVP_PKEY_free(cpk->privatekey);
#if 0
if (c->pkeys[i].publickey != NULL)
EVP_PKEY_free(c->pkeys[i].publickey);