From 4d74b203afd6fd99b129bf5595a38902f71b0284 Mon Sep 17 00:00:00 2001 From: Stenzek Date: Thu, 26 Sep 2024 13:39:01 +1000 Subject: [PATCH] System: Don't try to read SYSTEM.CNF from Audio CD --- src/core/system.cpp | 5 ++++- src/util/iso_reader.cpp | 6 ++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/core/system.cpp b/src/core/system.cpp index 800463b88..8a1d76976 100644 --- a/src/core/system.cpp +++ b/src/core/system.cpp @@ -1086,8 +1086,11 @@ DiscRegion System::GetRegionFromSystemArea(CDImage* cdi) { // The license code is on sector 4 of the disc. u8 sector[CDImage::DATA_SECTOR_SIZE]; - if (!cdi->Seek(1, 4) || cdi->Read(CDImage::ReadMode::DataOnly, 1, sector) != 1) + if (cdi->GetTrackMode(1) == CDImage::TrackMode::Audio || !cdi->Seek(1, 4) || + cdi->Read(CDImage::ReadMode::DataOnly, 1, sector) != 1) + { return DiscRegion::Other; + } static constexpr char ntsc_u_string[] = " Licensed by Sony Computer Entertainment Amer ica "; static constexpr char ntsc_j_string[] = " Licensed by Sony Computer Entertainment Inc."; diff --git a/src/util/iso_reader.cpp b/src/util/iso_reader.cpp index b42f54e06..2f1b3fc18 100644 --- a/src/util/iso_reader.cpp +++ b/src/util/iso_reader.cpp @@ -29,6 +29,12 @@ bool IsoReader::Open(CDImage* image, u32 track_number, Error* error) m_image = image; m_track_number = track_number; + if (image->GetTrackMode(static_cast(track_number)) == CDImage::TrackMode::Audio) + { + Error::SetStringFmt(error, "Track {} is an audio track.", track_number); + return false; + } + if (!ReadPVD(error)) return false;