epass2003: Avoid memory leaks if no file_out is passed

Thanks oss-fuzz

https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20898
This commit is contained in:
Jakub Jelen 2020-03-02 16:57:11 +01:00 committed by Frank Morgner
parent a623226a87
commit 7d3b82c204
1 changed files with 5 additions and 2 deletions

View File

@ -1369,7 +1369,7 @@ epass2003_select_fid(struct sc_card *card, unsigned int id_hi, unsigned int id_l
sc_file_t ** file_out)
{
int r;
sc_file_t *file = 0;
sc_file_t *file = NULL;
sc_path_t path;
memset(&path, 0, sizeof(path));
@ -1396,8 +1396,11 @@ epass2003_select_fid(struct sc_card *card, unsigned int id_hi, unsigned int id_l
}
}
if (file_out)
if (file_out) {
*file_out = file;
} else {
sc_file_free(file);
}
LOG_FUNC_RETURN(card->ctx, SC_SUCCESS);
}