fixed memory leaks

This commit is contained in:
Frank Morgner 2019-01-15 10:07:20 +01:00
parent 83c4ebe9d6
commit 893be0d9c0
2 changed files with 13 additions and 7 deletions

View File

@ -367,8 +367,11 @@ static int mcrd_init(sc_card_t * card)
sc_format_path ("3f00", &tmppath);
r = sc_select_file (card, &tmppath, NULL);
if (r < 0)
if (r < 0) {
free(card->drv_data);
card->drv_data = NULL;
r = SC_ERROR_INVALID_CARD;
}
/* Not needed for the fixed EstEID profile */
if (!is_esteid_card(card))

View File

@ -1091,12 +1091,15 @@ piv_get_cached_data(sc_card_t * card, int enumtag, u8 **buf, size_t *buf_len)
priv->obj_cache[enumtag].internal_obj_data,
priv->obj_cache[enumtag].internal_obj_len);
} else if (r == 0 || r == SC_ERROR_FILE_NOT_FOUND) {
r = SC_ERROR_FILE_NOT_FOUND;
priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
priv->obj_cache[enumtag].obj_len = 0;
} else if ( r < 0) {
goto err;
} else {
free(rbuf);
if (r == 0 || r == SC_ERROR_FILE_NOT_FOUND) {
r = SC_ERROR_FILE_NOT_FOUND;
priv->obj_cache[enumtag].flags |= PIV_OBJ_CACHE_VALID;
priv->obj_cache[enumtag].obj_len = 0;
} else if ( r < 0) {
goto err;
}
}
ok: