if ( oldCertDBKey != NULL ) { SECITEM_FreeItem(oldCertDBKey, PR_TRUE); }
AddCertToSPKDigestTableForAlg(CERTCertDBHandle *handle, CERTCertificate *cert,			      SECItem *certDBKey, SECOidTag digestAlg){    SECStatus rv = SECFailure;    SECItem *oldCertDBKey = NULL;    PRBool addit = PR_TRUE;    CERTCertificate *oldCert = NULL;    char *index = NULL;    PLHashTable *table;    /*     * After running some testing doing key hash lookups (like using OCSP),     * if these are never hit, they can probably be removed.     */    PORT_Assert(handle != NULL);    PORT_Assert(handle == cert->dbhandle);    PORT_Assert(handle->spkDigestInfo != NULL);    PORT_Assert((certDBKey == &cert->certKey)		|| (SECITEM_CompareItem(certDBKey,					&cert->certKey) == SECEqual));    table = SPK_DIGEST_TABLE(handle);    PORT_Assert(table != NULL);    index = spkDigestIndexFromCert(cert, digestAlg);    if ( index == NULL ) {	goto loser;    }    /*     * See if this cert's spk digest is already in the table.     */    oldCertDBKey = PL_HashTableLookup(table, index);    if ( oldCertDBKey != NULL ) {	/*	 * The spk digest *is* already in the table.  We need to find that	 * cert and see -- if it is the same, then we can just leave as is.	 * Otherwise we have to choose which cert we want represented;	 * in that case the best plan I can think of is to hang onto the	 * most recent one.	 */	oldCert = CERT_FindCertByKey(handle, oldCertDBKey);	if ( oldCert != NULL ) {	    if ( cert == oldCert ) {		/* They are the same cert, so we are done. */		addit = PR_FALSE;		oldCertDBKey = NULL;		/* don't want to free it */	    } else if ( CERT_IsNewer(cert, oldCert) ) {		if ( PL_HashTableRemove(table, index) != PR_TRUE ) {		    goto loser;		}	    } else {		/* oldCert is "newer", so we are done. */		addit = PR_FALSE;		oldCertDBKey = NULL;		/* don't want to free it */	    }	}    }    if ( addit ) {	certDBKey = SECITEM_DupItem(certDBKey);	if ( certDBKey == NULL ) {	    goto loser;	}	if ( PL_HashTableAdd(table, index, certDBKey) == NULL ) {	    SECITEM_FreeItem(certDBKey, PR_TRUE);	    PORT_SetError(SEC_ERROR_NO_MEMORY);	    goto loser;	}	index = NULL;				/* don't want to free it */    }    rv = SECSuccess;loser:    if ( oldCertDBKey != NULL ) {	SECITEM_FreeItem(oldCertDBKey, PR_TRUE);    }    if ( index != NULL ) {	PORT_Free(index);    }    if ( oldCert != NULL ) {	CERT_DestroyCertificate(oldCert);    }    return(rv);}