From 4c0077fd84f9d9285e84fd721948110c286e0e33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Wed, 27 Sep 2023 00:07:06 +0200 Subject: [PATCH] Protect against weirdness in UnlinkBlocks (hopefully not needed after prev fix) --- Core/MIPS/JitCommon/JitBlockCache.cpp | 5 +++++ GPU/Common/SoftwareTransformCommon.cpp | 2 ++ 2 files changed, 7 insertions(+) diff --git a/Core/MIPS/JitCommon/JitBlockCache.cpp b/Core/MIPS/JitCommon/JitBlockCache.cpp index 8dee134ee495..f8ba2436c6e2 100644 --- a/Core/MIPS/JitCommon/JitBlockCache.cpp +++ b/Core/MIPS/JitCommon/JitBlockCache.cpp @@ -462,6 +462,11 @@ void JitBlockCache::UnlinkBlock(int i) { if (ppp.first == ppp.second) return; for (auto iter = ppp.first; iter != ppp.second; ++iter) { + if ((size_t)iter->second >= num_blocks_) { + // Something probably went very wrong. Try to stumble along nevertheless. + ERROR_LOG(JIT, "UnlinkBlock: Invalid block number %d", iter->second); + continue; + } JitBlock &sourceBlock = blocks_[iter->second]; for (int e = 0; e < MAX_JIT_BLOCK_EXITS; e++) { if (sourceBlock.exitAddress[e] == b.originalAddress) diff --git a/GPU/Common/SoftwareTransformCommon.cpp b/GPU/Common/SoftwareTransformCommon.cpp index 0b65c1bb4b4a..0ca1a1ee19d5 100644 --- a/GPU/Common/SoftwareTransformCommon.cpp +++ b/GPU/Common/SoftwareTransformCommon.cpp @@ -590,6 +590,8 @@ void SoftwareTransform::BuildDrawingParams(int prim, int vertexCount, u32 vertTy result->drawBuffer = transformedExpanded; result->drawIndexed = true; } else if (prim == GE_PRIM_LINES) { + // TODO: What about GE_PRIM_LINE_STRIP? + if (!ExpandLines(vertexCount, maxIndex, inds, indsOffset, indexBufferSize, transformed, transformedExpanded, numTrans, throughmode)) { result->drawIndexed = false; result->drawNumTrans = 0;