Bugzilla bug 135069: SEC_PKCS12DestroyExportContext should free the slot
authorwtc%netscape.com
Mon, 13 May 2002 17:22:46 +0000
changeset 3127 578b30fc350ef9c6ec30408f0a846976d8aa8974
parent 3126 efa36b3344c7affaf92bb7f29e7887e7fca3598b
child 3128 cf92b9a91fb7fc2fba186be6fa3e545306937e71
child 3154 82ee9fcac6e1cc0403006be250dbfccca8762b47
push idunknown
push userunknown
push dateunknown
bugs135069
Bugzilla bug 135069: SEC_PKCS12DestroyExportContext should free the slot reference allocated in SEC_PKCS12CreateExportContext. r=relyea,mcgreer.
security/nss/lib/pkcs12/p12e.c
--- a/security/nss/lib/pkcs12/p12e.c
+++ b/security/nss/lib/pkcs12/p12e.c
@@ -189,17 +189,17 @@ SEC_PKCS12CreateExportContext(SECKEYGetP
 
     /* password callback for key retrieval */
     p12ctxt->pwfn = pwfn;
     p12ctxt->pwfnarg = pwfnarg;
 
     p12ctxt->integrityEnabled = PR_FALSE;
     p12ctxt->arena = arena;
     p12ctxt->wincx = wincx;
-    p12ctxt->slot = (slot) ? slot : PK11_GetInternalSlot();
+    p12ctxt->slot = (slot) ? PK11_ReferenceSlot(slot) : PK11_GetInternalSlot();
 
     return p12ctxt;
 
 loser:
     if(arena) {
 	PORT_FreeArena(arena, PR_TRUE);
     }
 
@@ -2142,16 +2142,18 @@ SEC_PKCS12DestroyExportContext(SEC_PKCS1
 	    }
 	    if(p12ecx->safeInfos[i]->cinfo) {
 		SEC_PKCS7DestroyContentInfo(p12ecx->safeInfos[i]->cinfo);
 	    }
 	    i++;
 	}
     }
 
+    PK11_FreeSlot(p12ecx->slot);
+
     PORT_FreeArena(p12ecx->arena, PR_TRUE);
 }
 
 
 /*********************************
  * All-in-one routines for exporting certificates 
  *********************************/
 struct inPlaceEncodeInfo {