From 69fb8de6445fd12e036e3f89f703a64f307425c6 Mon Sep 17 00:00:00 2001 From: Connor McLaughlin Date: Wed, 12 May 2021 16:35:18 +1000 Subject: [PATCH] CDImageM3u: Fix crash when error pointer is null --- src/common/cd_image_m3u.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/common/cd_image_m3u.cpp b/src/common/cd_image_m3u.cpp index c64ad04db..9e0afbbb8 100644 --- a/src/common/cd_image_m3u.cpp +++ b/src/common/cd_image_m3u.cpp @@ -53,15 +53,16 @@ bool CDImageM3u::Open(const char* path, Common::Error* error) if (!fp) return false; - std::optional cue_file(FileSystem::ReadFileToString(fp)); + std::optional m3u_file(FileSystem::ReadFileToString(fp)); std::fclose(fp); - if (!cue_file.has_value() || cue_file->empty()) + if (!m3u_file.has_value() || m3u_file->empty()) { - error->SetMessage("Failed to read cue sheet"); + if (error) + error->SetMessage("Failed to read M3u file"); return false; } - std::istringstream ifs(cue_file.value()); + std::istringstream ifs(m3u_file.value()); m_filename = path; std::vector entries;