From 3b01e59cd4f431e9cf84f81c71c4a8db8edc331d Mon Sep 17 00:00:00 2001 From: Ani Date: Wed, 13 Mar 2019 00:13:09 +0000 Subject: [PATCH] InstallPup: Fix exception on newline trim Avoid throwing fatal error when installing firmware without a \n character on the version string Fixes #5646 --- rpcs3/rpcs3qt/main_window.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rpcs3/rpcs3qt/main_window.cpp b/rpcs3/rpcs3qt/main_window.cpp index 225ef3b772..6a8001ac05 100644 --- a/rpcs3/rpcs3qt/main_window.cpp +++ b/rpcs3/rpcs3qt/main_window.cpp @@ -565,7 +565,11 @@ void main_window::InstallPup(const QString& dropPath) updatefilenames.end()); std::string version_string = pup.get_file(0x100).to_string(); - version_string.erase(version_string.find('\n')); + size_t version_pos = version_string.find('\n'); + if (version_pos != std::string::npos) + { + version_string.erase(version_pos); + } const std::string cur_version = "4.84";