From abc035b15a9faa1d8e4d68de60eb353892ee8f04 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 21 Oct 2020 20:17:48 +1000 Subject: [PATCH] CDImage: Fix assert failing on invalid cuesheets --- src/common/cd_image_cue.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/common/cd_image_cue.cpp b/src/common/cd_image_cue.cpp index bdc79144e..876cbaa03 100644 --- a/src/common/cd_image_cue.cpp +++ b/src/common/cd_image_cue.cpp @@ -125,7 +125,13 @@ bool CDImageCueSheet::OpenAndParse(const char* filename) std::fseek(m_files[track_file_index].file, 0, SEEK_SET); file_size /= track_sector_size; - Assert(track_start < file_size); + if (track_start >= file_size) + { + Log_ErrorPrintf("Failed to open track %u in '%s': track start is out of range (%u vs %u)", track_num, filename, + track_start, file_size); + return false; + } + track_length = file_size - track_start; }