From 25c320aa4bd2daa634940c716455545f18cccbc5 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 6 Aug 2016 19:23:46 -0700 Subject: [PATCH 1/3] virtfs: Avoid crash if handler cannot be loaded. For example, if it was renamed or is for the wrong OS. --- Core/FileSystems/VirtualDiscFileSystem.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index 4e0c5be4b5..c1deef1ecb 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -112,13 +112,16 @@ void VirtualDiscFileSystem::LoadFileListIndex() { size_t handler_pos = line.find(':', filename_pos); if (handler_pos != line.npos) { entry.fileName = line.substr(filename_pos, handler_pos - filename_pos); + std::string handler = line.substr(handler_pos + 1); size_t trunc = handler.find_last_not_of("\r\n"); if (trunc != handler.npos && trunc != handler.size()) handler.resize(trunc + 1); + if (handlers.find(handler) == handlers.end()) handlers[handler] = new Handler(handler.c_str(), this); - entry.handler = handlers[handler]; + if (handlers[handler]->IsValid()) + entry.handler = handlers[handler]; } else { entry.fileName = line.substr(filename_pos); } From f101e2710c79610ffb0297562081db63d3d9b152 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 6 Aug 2016 20:01:50 -0700 Subject: [PATCH 2/3] Avoid a c++11 rule violation. No default args on lambdas, unfortunately...? --- GPU/Common/GPUStateUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/GPU/Common/GPUStateUtils.cpp b/GPU/Common/GPUStateUtils.cpp index eb38e02299..88467536e0 100644 --- a/GPU/Common/GPUStateUtils.cpp +++ b/GPU/Common/GPUStateUtils.cpp @@ -1204,12 +1204,12 @@ static void ConvertStencilFunc5551(GenericStencilFuncState &state) { const u8 maskedRef = state.testRef & state.testMask; const u8 usedRef = (state.testRef & 0x80) != 0 ? 0xFF : 0x00; - auto rewriteFunc = [&](GEComparison func, u8 ref, u8 mask = 0xFF) { + auto rewriteFunc = [&](GEComparison func, u8 ref) { // We can only safely rewrite if it doesn't use the ref, or if the ref is the same. if (!usesRef || usedRef == ref) { state.testFunc = func; state.testRef = ref; - state.testMask = mask; + state.testMask = 0xFF; } }; auto rewriteRef = [&](bool always) { From 92cdb583aafa8c4fa66876e724e274fd5b1c7b5e Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sat, 6 Aug 2016 20:04:50 -0700 Subject: [PATCH 3/3] virtfs: Log properly on handler load failure. --- Core/FileSystems/VirtualDiscFileSystem.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Core/FileSystems/VirtualDiscFileSystem.cpp b/Core/FileSystems/VirtualDiscFileSystem.cpp index c1deef1ecb..544b19502d 100644 --- a/Core/FileSystems/VirtualDiscFileSystem.cpp +++ b/Core/FileSystems/VirtualDiscFileSystem.cpp @@ -831,6 +831,8 @@ VirtualDiscFileSystem::Handler::Handler(const char *filename, VirtualDiscFileSys dlclose(library); library = NULL; } + } else { + ERROR_LOG(FILESYS, "Unable to load handler: %s", filename); } #ifdef _WIN32 #undef dlopen