pkcs15-pubkey.c: fixed potential resource leak

This commit is contained in:
Frank Morgner 2015-10-09 23:11:03 +02:00
parent 98b9b37e12
commit 0853ecd887
1 changed files with 3 additions and 1 deletions

View File

@ -1034,8 +1034,10 @@ sc_pkcs15_pubkey_from_prvkey(struct sc_context *ctx, struct sc_pkcs15_prkey *prv
break;
case SC_ALGORITHM_EC:
pubkey->u.ec.ecpointQ.value = malloc(prvkey->u.ec.ecpointQ.len);
if (!pubkey->u.ec.ecpointQ.value)
if (!pubkey->u.ec.ecpointQ.value) {
sc_pkcs15_free_pubkey(pubkey);
LOG_FUNC_RETURN(ctx, SC_ERROR_OUT_OF_MEMORY);
}
memcpy(pubkey->u.ec.ecpointQ.value, prvkey->u.ec.ecpointQ.value, prvkey->u.ec.ecpointQ.len);
pubkey->u.ec.ecpointQ.len = prvkey->u.ec.ecpointQ.len;
break;