diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 11fc491ef..e301d68ce 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -2,7 +2,7 @@ name: Feature request about: Suggest an idea for this project title: '' -labels: enhancement +labels: feature request assignees: '' --- diff --git a/src/cdrom/cdrom_image_backend.c b/src/cdrom/cdrom_image_backend.c index 983a75efa..61260b44d 100644 --- a/src/cdrom/cdrom_image_backend.c +++ b/src/cdrom/cdrom_image_backend.c @@ -9,7 +9,7 @@ * CD-ROM image file handling module, translated to C from * cdrom_dosbox.cpp. * - * Version: @(#)cdrom_image_backend.c 1.0.2 2020/01/11 + * Version: @(#)cdrom_image_backend.c 1.0.3 2020/01/13 * * Authors: Miran Grca, * Fred N. van Kempen, @@ -135,6 +135,13 @@ bin_init(const wchar_t *filename, int *error) { track_file_t *tf = (track_file_t *) malloc(sizeof(track_file_t)); + if (tf == NULL) { + tf->read = NULL; + tf->get_length = NULL; + tf->close = NULL; + return NULL; + } + memset(tf->fn, 0x00, sizeof(tf->fn)); wcscpy(tf->fn, filename); tf->file = plat_fopen64(tf->fn, L"rb"); @@ -147,6 +154,12 @@ bin_init(const wchar_t *filename, int *error) tf->read = bin_read; tf->get_length = bin_get_length; tf->close = bin_close; + } else { + free(tf); + tf = NULL; + tf->read = NULL; + tf->get_length = NULL; + tf->close = NULL; } return tf; @@ -508,7 +521,7 @@ cdi_load_iso(cd_img_t *cdi, const wchar_t *filename) /* Data track (shouldn't there be a lead in track?). */ trk.file = bin_init(filename, &error); if (error) { - if (trk.file != NULL) + if ((trk.file != NULL) && (trk.file->close != NULL)) trk.file->close(trk.file); return 0; }