From 61215e718028de2d4b0e302f2226e43d0051876f Mon Sep 17 00:00:00 2001 From: Scott Mansell Date: Sun, 25 Jan 2015 20:31:20 +1300 Subject: [PATCH] Fix a buffer underrun in CalculateZSlope. --- Source/Core/VideoCommon/VertexManagerBase.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Source/Core/VideoCommon/VertexManagerBase.cpp b/Source/Core/VideoCommon/VertexManagerBase.cpp index e34af09bfc..2ebb42122f 100644 --- a/Source/Core/VideoCommon/VertexManagerBase.cpp +++ b/Source/Core/VideoCommon/VertexManagerBase.cpp @@ -287,6 +287,10 @@ void VertexManager::CalculateZSlope(NativeVertexFormat* format) size_t posOff = vert_decl.position.offset; size_t mtxOff = vert_decl.posmtx.offset; + // Make sure the buffer contains at lest 3 vertices. + if ((s_pCurBufferPointer - s_pBaseBufferPointer) < (vert_decl.stride * 3)) + return; + // Lookup vertices of the last rendered triangle and software-transform them // This allows us to determine the depth slope, which will be used if z--freeze // is enabled in the following flush.