diff --git a/src/d3d8/d3d8_batch.h b/src/d3d8/d3d8_batch.h index 567e0d70b..d9120a49c 100644 --- a/src/d3d8/d3d8_batch.h +++ b/src/d3d8/d3d8_batch.h @@ -6,7 +6,6 @@ #include #include -#include namespace dxvk { @@ -83,7 +82,7 @@ namespace dxvk { D3DPRIMITIVETYPE PrimitiveType = D3DPT_INVALID; std::vector Indices; UINT Offset = 0; - UINT MinVertex = UINT_MAX; + UINT MinVertex = std::numeric_limits::max(); UINT MaxVertex = 0; UINT PrimitiveCount = 0; UINT DrawCallCount = 0; @@ -126,7 +125,7 @@ namespace dxvk { draw.PrimitiveType = D3DPRIMITIVETYPE(0); draw.Offset = 0; - draw.MinVertex = UINT_MAX; + draw.MinVertex = std::numeric_limits::max(); draw.MaxVertex = 0; draw.PrimitiveCount = 0; draw.DrawCallCount = 0; diff --git a/src/d3d8/d3d8_device.cpp b/src/d3d8/d3d8_device.cpp index b7c9a8945..88227c2c3 100644 --- a/src/d3d8/d3d8_device.cpp +++ b/src/d3d8/d3d8_device.cpp @@ -1481,7 +1481,7 @@ namespace dxvk { return GetD3D9()->DrawIndexedPrimitive( d3d9::D3DPRIMITIVETYPE(PrimitiveType), - static_cast(std::min(m_baseVertexIndex, static_cast(INT_MAX))), // set by SetIndices + static_cast(std::min(m_baseVertexIndex, static_cast(std::numeric_limits::max()))), // set by SetIndices MinVertexIndex, NumVertices, StartIndex, @@ -1621,7 +1621,7 @@ namespace dxvk { if (unlikely(ShouldRecord())) return m_recorder->SetIndices(pIndexData, BaseVertexIndex); - if (unlikely(BaseVertexIndex > INT_MAX)) + if (unlikely(BaseVertexIndex > std::numeric_limits::max())) Logger::warn("D3D8Device::SetIndices: BaseVertexIndex exceeds INT_MAX"); // used by DrawIndexedPrimitive diff --git a/src/d3d9/d3d9_device.cpp b/src/d3d9/d3d9_device.cpp index ae48e54bc..d2128512b 100644 --- a/src/d3d9/d3d9_device.cpp +++ b/src/d3d9/d3d9_device.cpp @@ -7693,6 +7693,10 @@ namespace dxvk { const uint32_t regCountHardware = DetermineHardwareRegCount(); constexpr uint32_t regCountSoftware = DetermineSoftwareRegCount(); + // Error out in case of StartRegister + Count overflow + if (unlikely(StartRegister > std::numeric_limits::max() - Count)) + return D3DERR_INVALIDCALL; + if (unlikely(StartRegister + Count > regCountSoftware)) return D3DERR_INVALIDCALL;