NSC_Finalize will now destroy 3 softoken free lists and one more
global pointer. Plugs some memory leaks. Bugscape bug 54301. r=wtc git-svn-id: svn://10.0.0.236/trunk@150099 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
d17fa8d67b
commit
91eaa1ae03
@ -218,6 +218,9 @@ nsslowcert_setDBVerify(NSSLOWCERTCertDBHandle *handle, PRBool value);
|
||||
PRBool
|
||||
nsslowcert_hasTrust(NSSLOWCERTCertTrust *trust);
|
||||
|
||||
void
|
||||
nsslowcert_DestroyFreeLists(void);
|
||||
|
||||
void
|
||||
nsslowcert_DestroyGlobalLocks(void);
|
||||
|
||||
|
||||
@ -34,7 +34,7 @@
|
||||
/*
|
||||
* Permanent Certificate database handling code
|
||||
*
|
||||
* $Id: pcertdb.c,v 1.46 2003-07-28 22:55:16 bishakhabanerjee%netscape.com Exp $
|
||||
* $Id: pcertdb.c,v 1.47 2003-12-06 06:41:51 nelsonb%netscape.com Exp $
|
||||
*/
|
||||
#include "prtime.h"
|
||||
|
||||
@ -1038,6 +1038,7 @@ CreateCertEntry(void)
|
||||
entryListCount--;
|
||||
entryListHead = entry->next;
|
||||
}
|
||||
PORT_Assert(entryListCount >= 0);
|
||||
nsslowcert_UnlockFreeList();
|
||||
if (entry) {
|
||||
return entry;
|
||||
@ -1046,6 +1047,22 @@ CreateCertEntry(void)
|
||||
return PORT_ZAlloc(sizeof(certDBEntryCert));
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyCertEntryFreeList(void)
|
||||
{
|
||||
certDBEntryCert *entry;
|
||||
|
||||
nsslowcert_LockFreeList();
|
||||
while (NULL != (entry = entryListHead)) {
|
||||
entryListCount--;
|
||||
entryListHead = entry->next;
|
||||
PORT_Free(entry);
|
||||
}
|
||||
PORT_Assert(!entryListCount);
|
||||
entryListCount = 0;
|
||||
nsslowcert_UnlockFreeList();
|
||||
}
|
||||
|
||||
/*
|
||||
* Read a certificate entry
|
||||
*/
|
||||
@ -2681,7 +2698,7 @@ nsslowcert_UpdateSubjectEmailAddr(NSSLOWCERTCertDBHandle *dbhandle,
|
||||
}
|
||||
|
||||
if ( entry->emailAddrs ) {
|
||||
for (i=0; i < entry->nemailAddrs; i++) {
|
||||
for (i=0; i < (int)(entry->nemailAddrs); i++) {
|
||||
if (PORT_Strcmp(entry->emailAddrs[i],emailAddr) == 0) {
|
||||
index = i;
|
||||
}
|
||||
@ -2695,7 +2712,7 @@ nsslowcert_UpdateSubjectEmailAddr(NSSLOWCERTCertDBHandle *dbhandle,
|
||||
}
|
||||
|
||||
entry->nemailAddrs--;
|
||||
for (i=index; i < entry->nemailAddrs; i++) {
|
||||
for (i=index; i < (int)(entry->nemailAddrs); i++) {
|
||||
entry->emailAddrs[i] = entry->emailAddrs[i+1];
|
||||
}
|
||||
} else {
|
||||
@ -2708,7 +2725,7 @@ nsslowcert_UpdateSubjectEmailAddr(NSSLOWCERTCertDBHandle *dbhandle,
|
||||
if (!newAddrs) {
|
||||
goto loser;
|
||||
}
|
||||
for (i=0; i < entry->nemailAddrs; i++) {
|
||||
for (i=0; i < (int)(entry->nemailAddrs); i++) {
|
||||
newAddrs[i] = entry->emailAddrs[i];
|
||||
}
|
||||
newAddrs[entry->nemailAddrs] =
|
||||
@ -4296,6 +4313,7 @@ CreateTrust(void)
|
||||
trustListCount--;
|
||||
trustListHead = trust->next;
|
||||
}
|
||||
PORT_Assert(trustListCount >= 0);
|
||||
nsslowcert_UnlockFreeList();
|
||||
if (trust) {
|
||||
return trust;
|
||||
@ -4304,9 +4322,25 @@ CreateTrust(void)
|
||||
return PORT_ZAlloc(sizeof(NSSLOWCERTTrust));
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyTrustFreeList(void)
|
||||
{
|
||||
NSSLOWCERTTrust *trust;
|
||||
|
||||
nsslowcert_LockFreeList();
|
||||
while (NULL != (trust = trustListHead)) {
|
||||
trustListCount--;
|
||||
trustListHead = trust->next;
|
||||
PORT_Free(trust);
|
||||
}
|
||||
PORT_Assert(!trustListCount);
|
||||
trustListCount = 0;
|
||||
nsslowcert_UnlockFreeList();
|
||||
}
|
||||
|
||||
static NSSLOWCERTTrust *
|
||||
DecodeTrustEntry(NSSLOWCERTCertDBHandle *handle, certDBEntryCert *entry, SECItem *dbKey)
|
||||
DecodeTrustEntry(NSSLOWCERTCertDBHandle *handle, certDBEntryCert *entry,
|
||||
SECItem *dbKey)
|
||||
{
|
||||
NSSLOWCERTTrust *trust = CreateTrust();
|
||||
if (trust == NULL) {
|
||||
@ -5000,14 +5034,30 @@ nsslowcert_CreateCert(void)
|
||||
certListHead = cert->next;
|
||||
certListCount--;
|
||||
}
|
||||
PORT_Assert(certListCount >= 0);
|
||||
nsslowcert_UnlockFreeList();
|
||||
|
||||
if (cert) {
|
||||
return cert;
|
||||
}
|
||||
return (NSSLOWCERTCertificate *) PORT_ZAlloc(sizeof(NSSLOWCERTCertificate));
|
||||
}
|
||||
|
||||
static void
|
||||
DestroyCertFreeList(void)
|
||||
{
|
||||
NSSLOWCERTCertificate *cert;
|
||||
|
||||
nsslowcert_LockFreeList();
|
||||
while (NULL != (cert = certListHead)) {
|
||||
certListCount--;
|
||||
certListHead = cert->next;
|
||||
PORT_Free(cert);
|
||||
}
|
||||
PORT_Assert(!certListCount);
|
||||
certListCount = 0;
|
||||
nsslowcert_UnlockFreeList();
|
||||
}
|
||||
|
||||
void
|
||||
nsslowcert_DestroyTrust(NSSLOWCERTTrust *trust)
|
||||
{
|
||||
@ -5248,8 +5298,21 @@ nsslowcert_SaveSMimeProfile(NSSLOWCERTCertDBHandle *dbhandle, char *emailAddr,
|
||||
return(rv);
|
||||
}
|
||||
|
||||
/* If the freeListLock doesn't exist when this function is called,
|
||||
** this function will create it, use it 3 times, and delete it.
|
||||
*/
|
||||
void
|
||||
nsslowcert_DestroyGlobalLocks()
|
||||
nsslowcert_DestroyFreeLists(void)
|
||||
{
|
||||
DestroyCertEntryFreeList();
|
||||
DestroyTrustFreeList();
|
||||
DestroyCertFreeList();
|
||||
PZ_DestroyLock(freeListLock);
|
||||
freeListLock = NULL;
|
||||
}
|
||||
|
||||
void
|
||||
nsslowcert_DestroyGlobalLocks(void)
|
||||
{
|
||||
if (dbLock) {
|
||||
PZ_DestroyLock(dbLock);
|
||||
|
||||
@ -2852,6 +2852,8 @@ CK_RV nsc_CommonFinalize (CK_VOID_PTR pReserved, PRBool isFIPS)
|
||||
return CKR_OK;
|
||||
}
|
||||
|
||||
pk11_CleanupFreeLists();
|
||||
nsslowcert_DestroyFreeLists();
|
||||
nsslowcert_DestroyGlobalLocks();
|
||||
|
||||
#ifdef LEAK_TEST
|
||||
@ -2867,7 +2869,6 @@ CK_RV nsc_CommonFinalize (CK_VOID_PTR pReserved, PRBool isFIPS)
|
||||
RNG_RNGShutdown();
|
||||
#endif
|
||||
|
||||
pk11_CleanupFreeLists();
|
||||
/* tell freeBL to clean up after itself */
|
||||
BL_Cleanup();
|
||||
/* clean up the default OID table */
|
||||
|
||||
@ -45,6 +45,7 @@
|
||||
#include "secasn1.h"
|
||||
#include "blapi.h"
|
||||
#include "secerr.h"
|
||||
#include "prnetdb.h" /* for PR_ntohl */
|
||||
|
||||
/*
|
||||
* ******************** Attribute Utilities *******************************
|
||||
@ -1323,7 +1324,6 @@ pk11_ConstrainAttribute(PK11Object *object, CK_ATTRIBUTE_TYPE type,
|
||||
PK11Attribute *attribute;
|
||||
unsigned int size;
|
||||
unsigned char *ptr;
|
||||
int i,j;
|
||||
|
||||
attribute = pk11_FindAttribute(object, type);
|
||||
if (!attribute) {
|
||||
@ -1922,7 +1922,6 @@ CK_RV
|
||||
pk11_GetULongAttribute(PK11Object *object, CK_ATTRIBUTE_TYPE type,
|
||||
CK_ULONG *longData)
|
||||
{
|
||||
int len;
|
||||
PK11Attribute *attribute;
|
||||
|
||||
attribute = pk11_FindAttribute(object, type);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user