move free of CERTCertificate's arena below the NSSCertificate. needed for the case when an NSSCertificate is freed without ever releasing a CERTCertificate.

This commit is contained in:
ian.mcgreer%sun.com 2002-01-08 18:51:18 +00:00
Родитель 8b98f0af90
Коммит 5be475d4e5
4 изменённых файлов: 31 добавлений и 16 удалений

Просмотреть файл

@ -435,6 +435,15 @@ CERT_DestroyCertificate(CERTCertificate *cert)
PORT_Assert(cert->referenceCount > 0);
refCount = --cert->referenceCount;
CERT_UnlockCertRefCount(cert);
if ( ( refCount == 0 ) && !cert->keepSession ) {
PRArenaPool *arena = cert->arena;
/* zero cert before freeing. Any stale references to this cert
* after this point will probably cause an exception. */
PORT_Memset(cert, 0, sizeof *cert);
cert = NULL;
/* free the arena that contains the cert. */
PORT_FreeArena(arena, PR_FALSE);
}
#else
if (tmp) {
/* delete the NSSCertificate */
@ -470,15 +479,6 @@ CERT_DestroyCertificate(CERTCertificate *cert)
refCount = 0;
}
#endif
if ( ( refCount == 0 ) && !cert->keepSession ) {
PRArenaPool *arena = cert->arena;
/* zero cert before freeing. Any stale references to this cert
* after this point will probably cause an exception. */
PORT_Memset(cert, 0, sizeof *cert);
cert = NULL;
/* free the arena that contains the cert. */
PORT_FreeArena(arena, PR_FALSE);
}
}
return;
}

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: certdecode.c,v $ $Revision: 1.9 $ $Date: 2002/01/08 15:37:39 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: certdecode.c,v $ $Revision: 1.10 $ $Date: 2002/01/08 18:51:16 $ $Name: $";
#endif /* DEBUG */
#ifndef PKIT_H
@ -179,6 +179,9 @@ nssDecodedCert_Destroy
nssDecodedCert *dc
)
{
if (!dc) {
return PR_FAILURE;
}
switch(dc->type) {
case NSSCertificateType_PKIX:
return nssDecodedPKIXCertificate_Destroy(dc);

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: certificate.c,v $ $Revision: 1.22 $ $Date: 2002/01/03 20:09:23 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: certificate.c,v $ $Revision: 1.23 $ $Date: 2002/01/08 18:51:16 $ $Name: $";
#endif /* DEBUG */
#ifndef NSSPKI_H
@ -79,8 +79,15 @@ NSSCertificate_Destroy
NSSCertificate *c
)
{
PRBool destroyed;
if (c) {
nssPKIObject_Destroy(&c->object);
nssDecodedCert *dc = c->decoding;
destroyed = nssPKIObject_Destroy(&c->object);
if (destroyed) {
if (dc) {
nssDecodedCert_Destroy(dc);
}
}
}
return PR_SUCCESS;
}
@ -178,8 +185,7 @@ nssCertificate_GetDecoding
)
{
if (!c->decoding) {
c->decoding = nssDecodedCert_Create(c->object.arena,
&c->encoding, c->type);
c->decoding = nssDecodedCert_Create(NULL, &c->encoding, c->type);
}
return c->decoding;
}

Просмотреть файл

@ -32,7 +32,7 @@
*/
#ifdef DEBUG
static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.21 $ $Date: 2002/01/08 15:37:40 $ $Name: $";
static const char CVS_ID[] = "@(#) $RCSfile: pki3hack.c,v $ $Revision: 1.22 $ $Date: 2002/01/08 18:51:18 $ $Name: $";
#endif /* DEBUG */
/*
@ -366,7 +366,13 @@ nssDecodedPKIXCertificate_Destroy
nssDecodedCert *dc
)
{
/*CERT_DestroyCertificate((CERTCertificate *)dc->data);*/
CERTCertificate *cert = (CERTCertificate *)dc->data;
PRArenaPool *arena = cert->arena;
/* zero cert before freeing. Any stale references to this cert
* after this point will probably cause an exception. */
PORT_Memset(cert, 0, sizeof *cert);
/* free the arena that contains the cert. */
PORT_FreeArena(arena, PR_FALSE);
nss_ZFreeIf(dc);
return PR_SUCCESS;
}