From dfbc27247a4d98e4d84767f9ff1d194f1b5bf607 Mon Sep 17 00:00:00 2001 From: narzoul Date: Sat, 8 May 2021 10:31:18 +0200 Subject: [PATCH] Fixed index buffer overflow Fixes a crash in Laghaim. See issue #98. --- DDrawCompat/D3dDdi/DrawPrimitive.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DDrawCompat/D3dDdi/DrawPrimitive.cpp b/DDrawCompat/D3dDdi/DrawPrimitive.cpp index aa572cc..1e553c4 100644 --- a/DDrawCompat/D3dDdi/DrawPrimitive.cpp +++ b/DDrawCompat/D3dDdi/DrawPrimitive.cpp @@ -7,7 +7,7 @@ namespace { - const UINT INDEX_BUFFER_SIZE = 256 * 1024; + const UINT INDEX_BUFFER_SIZE = D3DMAXNUMPRIMITIVES * 3 * sizeof(UINT16); const UINT VERTEX_BUFFER_SIZE = 1024 * 1024; UINT getVertexCount(D3DPRIMITIVETYPE primitiveType, UINT primitiveCount) @@ -203,7 +203,7 @@ namespace D3dDdi bool DrawPrimitive::appendPrimitives(D3DPRIMITIVETYPE primitiveType, INT baseVertexIndex, UINT primitiveCount, const UINT16* indices, UINT minIndex, UINT maxIndex) { - if ((m_batched.primitiveCount + primitiveCount) * 3 > D3DMAXNUMVERTICES) + if (m_batched.primitiveCount + primitiveCount > D3DMAXNUMPRIMITIVES) { return false; }