if (!oldie) { continue; }
PK11_TraverseCertsForNicknameInSlot(SECItem *nickname, PK11SlotInfo *slot,	SECStatus(* callback)(CERTCertificate*, void *), void *arg){#ifdef NSS_CLASSIC    pk11DoCertCallback caller;    pk11TraverseSlot callarg;    CK_OBJECT_CLASS certClass = CKO_CERTIFICATE;    CK_ATTRIBUTE theTemplate[] = {	{ CKA_CLASS, NULL, 0 },	{ CKA_LABEL, NULL, 0 },    };    CK_ATTRIBUTE *attr = theTemplate;    int templateSize = sizeof(theTemplate)/sizeof(theTemplate[0]);    if(!nickname) {	return SECSuccess;    }    PK11_SETATTRS(attr,CKA_CLASS, &certClass, sizeof(certClass)); attr++;    PK11_SETATTRS(attr,CKA_LABEL,nickname->data,nickname->len);    if (slot == NULL) {	return SECSuccess;    }    caller.noslotcallback = callback;    caller.callback = NULL;    caller.itemcallback = NULL;    caller.callbackArg = arg;    callarg.callback = pk11_DoCerts;    callarg.callbackArg = (void *) & caller;    callarg.findTemplate = theTemplate;    callarg.templateCount = templateSize;    return PK11_TraverseSlot(slot, &callarg);#else    struct nss3_cert_cbstr pk11cb;    PRStatus nssrv = PR_SUCCESS;    NSSToken *token;    NSSTrustDomain *td;    NSSUTF8 *nick;    PRBool created = PR_FALSE;    nssCryptokiObject **instances;    nssPKIObjectCollection *collection = NULL;    NSSCertificate **certs;    nssList *nameList = NULL;    nssTokenSearchType tokenOnly = nssTokenSearchType_TokenOnly;    pk11cb.callback = callback;    pk11cb.arg = arg;    token = PK11Slot_GetNSSToken(slot);    if (!nssToken_IsPresent(token)) {	return SECSuccess;    }    if (nickname->data[nickname->len-1] != '\0') {	nick = nssUTF8_Create(NULL, nssStringType_UTF8String, 	                      nickname->data, nickname->len);	created = PR_TRUE;    } else {	nick = (NSSUTF8 *)nickname->data;    }    td = STAN_GetDefaultTrustDomain();    collection = nssCertificateCollection_Create(td, NULL);    if (!collection) {	goto loser;    }    nameList = nssList_Create(NULL, PR_FALSE);    if (!nameList) {	goto loser;    }    (void)nssTrustDomain_GetCertsForNicknameFromCache(td, nick, nameList);    transfer_token_certs_to_collection(nameList, token, collection);    instances = nssToken_FindCertificatesByNickname(token, NULL,	                                            nick,	                                            tokenOnly, 0, &nssrv);    nssPKIObjectCollection_AddInstances(collection, instances, 0);    nss_ZFreeIf(instances);    nssList_Destroy(nameList);    certs = nssPKIObjectCollection_GetCertificates(collection,                                                   NULL, 0, NULL);    nssPKIObjectCollection_Destroy(collection);    if (certs) {	CERTCertificate *oldie;	NSSCertificate **cp;	for (cp = certs; *cp; cp++) {	    oldie = STAN_GetCERTCertificate(*cp);	    if ((*callback)(oldie, arg) != SECSuccess) {		nssrv = PR_FAILURE;		break;	    }	}	nssCertificateArray_Destroy(certs);    }    if (created) nss_ZFreeIf(nick);    return (nssrv == PR_SUCCESS) ? SECSuccess : SECFailure;loser:    if (created) {	nss_ZFreeIf(nick);    }    if (collection) {	nssPKIObjectCollection_Destroy(collection);    }    if (nameList) {	nssList_Destroy(nameList);    }    return SECFailure;#endif}