bug 1205767 - prevent memory leak when generating an EC key with <keygen> r=ttaubert

This commit is contained in:
David Keeler 2015-09-17 14:57:24 -07:00
parent acdd60dddc
commit a81ffd22d7

View File

@ -481,7 +481,7 @@ nsKeygenFormProcessor::GetPublicKey(const nsAString& aValue,
PK11RSAGenParams rsaParams;
SECOidTag algTag;
int keysize = 0;
void *params;
void *params = nullptr;
SECKEYPrivateKey *privateKey = nullptr;
SECKEYPublicKey *publicKey = nullptr;
CERTSubjectPublicKeyInfo *spkInfo = nullptr;
@ -766,6 +766,12 @@ loser:
if (pkac.challenge.data) {
free(pkac.challenge.data);
}
// If params is non-null and doesn't point to rsaParams, it was allocated
// in decode_ec_params. We have to free this memory.
if (params && params != &rsaParams) {
SECITEM_FreeItem(static_cast<SECItem*>(params), true);
params = nullptr;
}
return rv;
}