From aa3b026bfe666dedb7f2911656ae59e4065d60b3 Mon Sep 17 00:00:00 2001 From: "Unknown W. Brackets" Date: Sun, 16 Dec 2018 13:16:05 -0800 Subject: [PATCH] SoftGPU: Fix crash on garbage index data. --- GPU/Software/TransformUnit.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/GPU/Software/TransformUnit.cpp b/GPU/Software/TransformUnit.cpp index c7799eaf3e..f6e8d6868c 100644 --- a/GPU/Software/TransformUnit.cpp +++ b/GPU/Software/TransformUnit.cpp @@ -581,12 +581,16 @@ bool TransformUnit::GetCurrentSimpleVertices(int count, std::vector temp_buffer; static std::vector simpleVertices; - temp_buffer.resize(65536 * 24 / sizeof(u32)); + temp_buffer.resize(std::max((int)indexUpperBound, 8192) * 128 / sizeof(u32)); simpleVertices.resize(indexUpperBound + 1); VertexDecoder vdecoder; VertexDecoderOptions options{}; vdecoder.SetVertexType(gstate.vertType, options); + + if (!Memory::IsValidRange(gstate_c.vertexAddr, (indexUpperBound + 1) * vdecoder.VertexSize())) + return false; + DrawEngineCommon::NormalizeVertices((u8 *)(&simpleVertices[0]), (u8 *)(&temp_buffer[0]), Memory::GetPointer(gstate_c.vertexAddr), &vdecoder, indexLowerBound, indexUpperBound, gstate.vertType); float world[16];