Fixed Dereference before null check

As reported by coverity scan
This commit is contained in:
Frank Morgner 2020-01-31 16:27:06 +01:00
parent 0fd77d642c
commit 72836fa3cb
3 changed files with 7 additions and 3 deletions

View File

@ -505,7 +505,7 @@ static int idprime_select_file(sc_card_t *card, const sc_path_t *in_path, sc_fil
priv->cached = 0;
r = iso_ops->select_file(card, in_path, file_out);
if (r == SC_SUCCESS && priv && file_out != NULL) {
if (r == SC_SUCCESS && file_out != NULL) {
/* Try to read first bytes of the file to fix FCI in case of
* compressed certififcate */
len = iso_ops->read_binary(card, 0, data, data_len, 0);

View File

@ -1871,7 +1871,7 @@ sc_pkcs15init_store_public_key(struct sc_pkcs15_card *p15card, struct sc_profile
profile->dirty = 1;
err:
if (object && r < 0)
if (r < 0)
sc_pkcs15init_free_object(object);
LOG_FUNC_RETURN(ctx, r);

View File

@ -132,8 +132,12 @@ static char * get_pin(struct sc_pkcs15_object *obj)
{
char buf[(sizeof obj->label) + 20];
char *pincode;
struct sc_pkcs15_auth_info *pinfo = (struct sc_pkcs15_auth_info *) obj->data;
struct sc_pkcs15_auth_info *pinfo;
if (!obj)
return NULL;
pinfo = (struct sc_pkcs15_auth_info *) obj->data;
if (pinfo->auth_type != SC_PKCS15_PIN_AUTH_TYPE_PIN)
return NULL;