Index: mozilla/security/nss/lib/pk11wrap/pk11pk12.c =================================================================== RCS file: /cvsroot/mozilla/security/nss/lib/pk11wrap/pk11pk12.c,v retrieving revision 1.10 diff -pU15 -r1.10 mozilla/security/nss/lib/pk11wrap/pk11pk12.c --- mozilla/security/nss/lib/pk11wrap/pk11pk12.c +++ mozilla/security/nss/lib/pk11wrap/pk11pk12.c @@ -238,47 +238,51 @@ PK11_ImportDERPrivateKeyInfo(PK11SlotInf return PK11_ImportDERPrivateKeyInfoAndReturnKey(slot, derPKI, nickname, publicValue, isPerm, isPrivate, keyUsage, NULL, wincx); } SECStatus PK11_ImportDERPrivateKeyInfoAndReturnKey(PK11SlotInfo *slot, SECItem *derPKI, SECItem *nickname, SECItem *publicValue, PRBool isPerm, PRBool isPrivate, unsigned int keyUsage, SECKEYPrivateKey** privk, void *wincx) { SECKEYPrivateKeyInfo *pki = NULL; PRArenaPool *temparena = NULL; SECStatus rv = SECFailure; temparena = PORT_NewArena(DER_DEFAULT_CHUNKSIZE); + if (!temparena) + return rv; pki = PORT_ArenaZNew(temparena, SECKEYPrivateKeyInfo); + if (!pki) { + PORT_FreeArena(temparena, PR_FALSE); + return rv; + } pki->arena = temparena; rv = SEC_ASN1DecodeItem(pki->arena, pki, SECKEY_PrivateKeyInfoTemplate, derPKI); if( rv != SECSuccess ) { goto finish; } rv = PK11_ImportPrivateKeyInfoAndReturnKey(slot, pki, nickname, publicValue, isPerm, isPrivate, keyUsage, privk, wincx); finish: - if( pki != NULL ) { - /* this zeroes the key and frees the arena */ - SECKEY_DestroyPrivateKeyInfo(pki, PR_TRUE /*freeit*/); - } + /* this zeroes the key and frees the arena */ + SECKEY_DestroyPrivateKeyInfo(pki, PR_TRUE /*freeit*/); return rv; } SECStatus PK11_ImportAndReturnPrivateKey(PK11SlotInfo *slot, SECKEYRawPrivateKey *lpk, SECItem *nickname, SECItem *publicValue, PRBool isPerm, PRBool isPrivate, unsigned int keyUsage, SECKEYPrivateKey **privk, void *wincx) { CK_BBOOL cktrue = CK_TRUE; CK_BBOOL ckfalse = CK_FALSE; CK_OBJECT_CLASS keyClass = CKO_PRIVATE_KEY; CK_KEY_TYPE keyType = CKK_RSA; CK_OBJECT_HANDLE objectID; CK_ATTRIBUTE theTemplate[20];