SoftGPU: Fix crash on garbage index data.

This commit is contained in:
Unknown W. Brackets 2018-12-16 13:16:05 -08:00
parent 0f880696be
commit aa3b026bfe

View file

@ -581,12 +581,16 @@ bool TransformUnit::GetCurrentSimpleVertices(int count, std::vector<GPUDebugVert
static std::vector<u32> temp_buffer; static std::vector<u32> temp_buffer;
static std::vector<SimpleVertex> simpleVertices; static std::vector<SimpleVertex> simpleVertices;
temp_buffer.resize(65536 * 24 / sizeof(u32)); temp_buffer.resize(std::max((int)indexUpperBound, 8192) * 128 / sizeof(u32));
simpleVertices.resize(indexUpperBound + 1); simpleVertices.resize(indexUpperBound + 1);
VertexDecoder vdecoder; VertexDecoder vdecoder;
VertexDecoderOptions options{}; VertexDecoderOptions options{};
vdecoder.SetVertexType(gstate.vertType, 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); DrawEngineCommon::NormalizeVertices((u8 *)(&simpleVertices[0]), (u8 *)(&temp_buffer[0]), Memory::GetPointer(gstate_c.vertexAddr), &vdecoder, indexLowerBound, indexUpperBound, gstate.vertType);
float world[16]; float world[16];