pkcs15-pubkey.c: fixed potential resource leak
This commit is contained in:
parent
98b9b37e12
commit
0853ecd887
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue