From 986bb243265af17256306e1931930ba6c919b716 Mon Sep 17 00:00:00 2001 From: RipleyTom Date: Fri, 9 Nov 2018 22:12:35 +0100 Subject: [PATCH] Extra check when opening pup file --- rpcs3/Loader/PUP.cpp | 8 +++++++- rpcs3/rpcs3qt/main_window.cpp | 9 ++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/rpcs3/Loader/PUP.cpp b/rpcs3/Loader/PUP.cpp index 9928251f84..ecc762ebf9 100644 --- a/rpcs3/Loader/PUP.cpp +++ b/rpcs3/Loader/PUP.cpp @@ -1,9 +1,15 @@ -#include "stdafx.h" +#include "stdafx.h" #include "PUP.h" pup_object::pup_object(const fs::file& file): m_file(file) { + if (!file) + { + isValid = false; + return; + } + PUPHeader m_header; m_file.read(m_header); if (m_header.magic != "SCEUF\0\0\0"_u64) diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 2a396bb121..fb2108bde8 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -1,4 +1,4 @@ - + #include #include #include @@ -532,6 +532,13 @@ void main_window::InstallPup(const QString& dropPath) const std::string path = sstr(filePath); fs::file pup_f(path); + if (!pup_f) + { + LOG_ERROR(GENERAL, "Error opening PUP file %s", path); + QMessageBox::critical(this, tr("Failure!"), tr("The selected firmware file couldn't be opened.")); + return; + } + pup_object pup(pup_f); if (!pup) {