Fix memleak (#1255)

This commit is contained in:
edgarholleis 2018-01-29 10:30:03 +01:00 committed by Frank Morgner
parent e5699ef04b
commit a7b066cc83
1 changed files with 12 additions and 1 deletions

View File

@ -4626,7 +4626,18 @@ get_ec_pubkey_point(struct sc_pkcs15_pubkey *key, CK_ATTRIBUTE_PTR attr)
if (rc != SC_SUCCESS)
return sc_to_cryptoki_error(rc, NULL);
check_attribute_buffer(attr, value_len);
if (attr->pValue == NULL_PTR) {
attr->ulValueLen = value_len;
free(value);
return CKR_OK;
}
if (attr->ulValueLen < value_len) {
attr->ulValueLen = value_len;
free(value);
return CKR_BUFFER_TOO_SMALL;
}
attr->ulValueLen = value_len;
memcpy(attr->pValue, value, value_len);
free(value);
return CKR_OK;