framework-pkcs15: Avoid leaking memory when create object fails

This commit is contained in:
Jakub Jelen 2020-12-01 10:34:18 +01:00 committed by Frank Morgner
parent 96ae693d5a
commit 219c6cc494
1 changed files with 6 additions and 2 deletions

View File

@ -833,10 +833,14 @@ __pkcs15_create_profile_object(struct pkcs15_fw_data *fw_data,
rv = __pkcs15_create_object(fw_data, (struct pkcs15_any_object **) &pobj,
obj, &pkcs15_profile_ops, sizeof(struct pkcs15_profile_object));
if (rv >= 0) {
pobj->profile_id = public_certificates ? CKP_PUBLIC_CERTIFICATES_TOKEN : CKP_AUTHENTICATION_TOKEN;
if (rv != SC_SUCCESS) {
free(obj);
return rv;
}
pobj->profile_id = public_certificates ? CKP_PUBLIC_CERTIFICATES_TOKEN : CKP_AUTHENTICATION_TOKEN;
if (profile_object != NULL)
*profile_object = (struct pkcs15_any_object *) pobj;