Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
From b3a543fc2616501555997d7caf857a74c9c197a7 Mon Sep 17 00:00:00 2001
Bug 1162897,  Make NSSTrustDomain_FindTokenByName() take a ref on the token it returns, r=rrelyea
  • Loading branch information
David Woodhouse authored and David Woodhouse committed Aug 19, 2016
1 parent 268cb85 commit b1d074b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 5 additions & 2 deletions lib/pk11wrap/pk11cert.c
Expand Up @@ -512,7 +512,7 @@ find_certs_from_nickname(const char *nickname, void *wincx)
{
PRStatus status;
NSSCertificate **certs = NULL;
NSSToken *token;
NSSToken *token = NULL;
NSSTrustDomain *defaultTD = STAN_GetDefaultTrustDomain();
PK11SlotInfo *slot = NULL;
SECStatus rv;
Expand All @@ -539,7 +539,7 @@ find_certs_from_nickname(const char *nickname, void *wincx)
*delimit = ':';
} else {
slot = PK11_GetInternalKeySlot();
token = PK11Slot_GetNSSToken(slot);
token = nssToken_AddRef(PK11Slot_GetNSSToken(slot));
}
if (token) {
nssList *certList;
Expand Down Expand Up @@ -600,6 +600,9 @@ find_certs_from_nickname(const char *nickname, void *wincx)
nssList_Destroy(certList);
}
loser:
if (token) {
nssToken_Destroy(token);
}
if (slot) {
PK11_FreeSlot(slot);
}
Expand Down
4 changes: 3 additions & 1 deletion lib/pki/trustdomain.c
Expand Up @@ -248,8 +248,10 @@ NSSTrustDomain_FindTokenByName(
tok = (NSSToken *)nssListIterator_Next(td->tokens)) {
if (nssToken_IsPresent(tok)) {
myName = nssToken_GetName(tok);
if (nssUTF8_Equal(tokenName, myName, &nssrv))
if (nssUTF8_Equal(tokenName, myName, &nssrv)) {
tok = nssToken_AddRef(tok);
break;
}
}
}
nssListIterator_Finish(td->tokens);
Expand Down

0 comments on commit b1d074b

Please sign in to comment.