From 893268bba55f815cf110ea63eccf4516346a976d Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Thu, 15 Oct 2020 18:08:18 +1000 Subject: [PATCH] CDImage: Fix crash on invalid cue/chd with no tracks --- src/common/cd_image_chd.cpp | 6 ++++++ src/common/cd_image_cue.cpp | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/src/common/cd_image_chd.cpp b/src/common/cd_image_chd.cpp index d7711f33e..afd26066d 100644 --- a/src/common/cd_image_chd.cpp +++ b/src/common/cd_image_chd.cpp @@ -238,6 +238,12 @@ bool CDImageCHD::Open(const char* filename) file_lba = Common::AlignUp(file_lba, CHD_CD_TRACK_ALIGNMENT); } + if (m_tracks.empty()) + { + Log_ErrorPrintf("File '%s' contains no tracks", filename); + return false; + } + m_lba_count = disc_lba; AddLeadOutIndex(); diff --git a/src/common/cd_image_cue.cpp b/src/common/cd_image_cue.cpp index 96a58d533..bdc79144e 100644 --- a/src/common/cd_image_cue.cpp +++ b/src/common/cd_image_cue.cpp @@ -217,6 +217,12 @@ bool CDImageCueSheet::OpenAndParse(const char* filename) } } + if (m_tracks.empty()) + { + Log_ErrorPrintf("File '%s' contains no tracks", filename); + return false; + } + m_lba_count = disc_lba; AddLeadOutIndex();