Plug leaks. Bug 123693. r=wtc,relyea
git-svn-id: svn://10.0.0.236/trunk@152034 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -2455,6 +2455,9 @@ pk11_DBVerify(PK11Slot *slot)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* forward static declaration. */
|
||||||
|
static CK_RV pk11_DestroySlotData(PK11Slot *slot);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* initialize one of the slot structures. figure out which by the ID
|
* initialize one of the slot structures. figure out which by the ID
|
||||||
*/
|
*/
|
||||||
@@ -2485,47 +2488,40 @@ PK11_SlotInit(char *configdir,pk11_token_parameters *params, int moduleIndex)
|
|||||||
|
|
||||||
#ifdef PKCS11_USE_THREADS
|
#ifdef PKCS11_USE_THREADS
|
||||||
slot->slotLock = PZ_NewLock(nssILockSession);
|
slot->slotLock = PZ_NewLock(nssILockSession);
|
||||||
if (slot->slotLock == NULL) {
|
if (slot->slotLock == NULL)
|
||||||
return CKR_HOST_MEMORY;
|
goto mem_loser;
|
||||||
}
|
slot->sessionLock = PORT_ZNewArray(PZLock *, slot->numSessionLocks);
|
||||||
slot->sessionLock = (PZLock **)
|
if (slot->sessionLock == NULL)
|
||||||
PORT_ZAlloc(slot->numSessionLocks * sizeof(PZLock *));
|
goto mem_loser;
|
||||||
if (slot->sessionLock == NULL) {
|
|
||||||
return CKR_HOST_MEMORY;
|
|
||||||
}
|
|
||||||
for (i=0; i < slot->numSessionLocks; i++) {
|
for (i=0; i < slot->numSessionLocks; i++) {
|
||||||
slot->sessionLock[i] = PZ_NewLock(nssILockSession);
|
slot->sessionLock[i] = PZ_NewLock(nssILockSession);
|
||||||
if (slot->sessionLock[i] == NULL) return CKR_HOST_MEMORY;
|
if (slot->sessionLock[i] == NULL)
|
||||||
|
goto mem_loser;
|
||||||
}
|
}
|
||||||
slot->objectLock = PZ_NewLock(nssILockObject);
|
slot->objectLock = PZ_NewLock(nssILockObject);
|
||||||
if (slot->objectLock == NULL) return CKR_HOST_MEMORY;
|
if (slot->objectLock == NULL)
|
||||||
|
goto mem_loser;
|
||||||
#else
|
#else
|
||||||
slot->slotLock = NULL;
|
slot->slotLock = NULL;
|
||||||
slot->sessionLock = (PZLock **)
|
slot->sessionLock = PORT_ZNewArray(PZLock *, slot->numSessionLocks);
|
||||||
PORT_ZAlloc(slot->numSessionLocks * sizeof(PZLock *));
|
if (slot->sessionLock == NULL)
|
||||||
if (slot->sessionLock == NULL) {
|
goto mem_loser;
|
||||||
return CKR_HOST_MEMORY;
|
|
||||||
}
|
|
||||||
for (i=0; i < slot->numSessionLocks; i++) {
|
for (i=0; i < slot->numSessionLocks; i++) {
|
||||||
slot->sessionLock[i] = NULL;
|
slot->sessionLock[i] = NULL;
|
||||||
}
|
}
|
||||||
slot->objectLock = NULL;
|
slot->objectLock = NULL;
|
||||||
#endif
|
#endif
|
||||||
slot->head = (PK11Session **)
|
slot->head = PORT_ZNewArray(PK11Session *, slot->sessHashSize);
|
||||||
PORT_ZAlloc(slot->sessHashSize*sizeof(PK11Session *));
|
if (slot->head == NULL)
|
||||||
if (slot->head == NULL) {
|
goto mem_loser;
|
||||||
return CKR_HOST_MEMORY;
|
slot->tokObjects = PORT_ZNewArray(PK11Object *, slot->tokObjHashSize);
|
||||||
}
|
if (slot->tokObjects == NULL)
|
||||||
slot->tokObjects = (PK11Object **)
|
goto mem_loser;
|
||||||
PORT_ZAlloc(slot->tokObjHashSize*sizeof(PK11Object *));
|
|
||||||
if (slot->tokObjects == NULL) {
|
|
||||||
return CKR_HOST_MEMORY;
|
|
||||||
}
|
|
||||||
slot->tokenHashTable = PL_NewHashTable(64,pk11_HashNumber,PL_CompareValues,
|
slot->tokenHashTable = PL_NewHashTable(64,pk11_HashNumber,PL_CompareValues,
|
||||||
SECITEM_HashCompare, NULL, 0);
|
SECITEM_HashCompare, NULL, 0);
|
||||||
if (slot->tokenHashTable == NULL) {
|
if (slot->tokenHashTable == NULL)
|
||||||
return CKR_HOST_MEMORY;
|
goto mem_loser;
|
||||||
}
|
|
||||||
slot->password = NULL;
|
slot->password = NULL;
|
||||||
slot->hasTokens = PR_FALSE;
|
slot->hasTokens = PR_FALSE;
|
||||||
slot->sessionIDCount = 0;
|
slot->sessionIDCount = 0;
|
||||||
@@ -2555,8 +2551,7 @@ PK11_SlotInit(char *configdir,pk11_token_parameters *params, int moduleIndex)
|
|||||||
params->noCertDB, params->noKeyDB, params->forceOpen,
|
params->noCertDB, params->noKeyDB, params->forceOpen,
|
||||||
&slot->certDB, &slot->keyDB);
|
&slot->certDB, &slot->keyDB);
|
||||||
if (crv != CKR_OK) {
|
if (crv != CKR_OK) {
|
||||||
/* shoutdown slot? */
|
goto loser;
|
||||||
return crv;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsslowcert_needDBVerify(slot->certDB)) {
|
if (nsslowcert_needDBVerify(slot->certDB)) {
|
||||||
@@ -2576,6 +2571,13 @@ PK11_SlotInit(char *configdir,pk11_token_parameters *params, int moduleIndex)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
return CKR_OK;
|
return CKR_OK;
|
||||||
|
|
||||||
|
mem_loser:
|
||||||
|
crv = CKR_HOST_MEMORY;
|
||||||
|
loser:
|
||||||
|
/* cleanup partially created SlotData */
|
||||||
|
pk11_DestroySlotData(slot);
|
||||||
|
return crv;
|
||||||
}
|
}
|
||||||
|
|
||||||
static PRIntn
|
static PRIntn
|
||||||
|
|||||||
Reference in New Issue
Block a user