From ed1609636554496a9e2eb91231d599131fff0be5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Tue, 7 Mar 2017 15:19:20 +0100 Subject: [PATCH] Don't crash if not enough memory to save a state. Very annoying. Minor tweaks. --- Common/ChunkFile.h | 9 ++++++++- Core/MIPS/ARM/ArmCompVFPUNEON.cpp | 2 +- GPU/D3D11/ShaderManagerD3D11.cpp | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/Common/ChunkFile.h b/Common/ChunkFile.h index ac923c15d2..ad318ff80c 100644 --- a/Common/ChunkFile.h +++ b/Common/ChunkFile.h @@ -576,6 +576,7 @@ public: ERROR_NONE, ERROR_BAD_FILE, ERROR_BROKEN_STATE, + ERROR_BAD_ALLOC, }; // May fail badly if ptr doesn't point to valid data. @@ -642,7 +643,13 @@ public: { // Get data size_t const sz = MeasurePtr(_class); - u8 *buffer = new u8[sz]; + u8 *buffer = nullptr; + try { + buffer = new u8[sz]; + } + catch (std::bad_alloc e) { + return ERROR_BAD_ALLOC; + } Error error = SavePtr(buffer, _class); // SaveFile takes ownership of buffer diff --git a/Core/MIPS/ARM/ArmCompVFPUNEON.cpp b/Core/MIPS/ARM/ArmCompVFPUNEON.cpp index 48e2f0fbd2..9db9a2e6ed 100644 --- a/Core/MIPS/ARM/ArmCompVFPUNEON.cpp +++ b/Core/MIPS/ARM/ArmCompVFPUNEON.cpp @@ -899,7 +899,7 @@ void ArmJit::CompNEON_Vmscl(MIPSOpcode op) { MatrixSize msz = GetMtxSize(op); - bool overlap = GetMatrixOverlap(_VD, _VS, msz); + bool overlap = GetMatrixOverlap(_VD, _VS, msz) != OVERLAP_NONE; if (overlap) { DISABLE; } diff --git a/GPU/D3D11/ShaderManagerD3D11.cpp b/GPU/D3D11/ShaderManagerD3D11.cpp index 449daa05bb..18046d7512 100644 --- a/GPU/D3D11/ShaderManagerD3D11.cpp +++ b/GPU/D3D11/ShaderManagerD3D11.cpp @@ -95,9 +95,9 @@ ShaderManagerD3D11::ShaderManagerD3D11(ID3D11Device *device, ID3D11DeviceContext memset(&ub_lights, 0, sizeof(ub_lights)); memset(&ub_bones, 0, sizeof(ub_bones)); - ILOG("sizeof(ub_base): %d", (int)sizeof(ub_base)); - ILOG("sizeof(ub_lights): %d", (int)sizeof(ub_lights)); - ILOG("sizeof(ub_bones): %d", (int)sizeof(ub_bones)); + INFO_LOG(G3D, "sizeof(ub_base): %d", (int)sizeof(ub_base)); + INFO_LOG(G3D, "sizeof(ub_lights): %d", (int)sizeof(ub_lights)); + INFO_LOG(G3D, "sizeof(ub_bones): %d", (int)sizeof(ub_bones)); D3D11_BUFFER_DESC desc{sizeof(ub_base), D3D11_USAGE_DYNAMIC, D3D11_BIND_CONSTANT_BUFFER, D3D11_CPU_ACCESS_WRITE }; ASSERT_SUCCESS(device_->CreateBuffer(&desc, nullptr, &push_base));