diff --git a/src/d3d9/d3d9_bridge.cpp b/src/d3d9/d3d9_bridge.cpp index 19a637f84..cf10e07d3 100644 --- a/src/d3d9/d3d9_bridge.cpp +++ b/src/d3d9/d3d9_bridge.cpp @@ -45,6 +45,26 @@ namespace dxvk { if (unlikely(dst == nullptr || src == nullptr)) return D3DERR_INVALIDCALL; + // CopyRects will not pass a null pSrcRect, but check anyway + if (unlikely(pSrcRect == nullptr)) + return D3DERR_INVALIDCALL; + + // validate dimensions to ensure we calculate a meaningful srcOffset & extent + if (unlikely(pSrcRect->left < 0 + || pSrcRect->top < 0 + || pSrcRect->right <= pSrcRect->left + || pSrcRect->bottom <= pSrcRect->top)) + return D3DERR_INVALIDCALL; + + // CopyRects will not pass a null pDestPoint, but check anyway + if (unlikely(pDestPoint == nullptr)) + return D3DERR_INVALIDCALL; + + // validate dimensions to ensure we caculate a meaningful dstOffset + if (unlikely(pDestPoint->x < 0 + || pDestPoint->y < 0)) + return D3DERR_INVALIDCALL; + D3D9CommonTexture* srcTextureInfo = src->GetCommonTexture(); D3D9CommonTexture* dstTextureInfo = dst->GetCommonTexture(); @@ -59,13 +79,10 @@ namespace dxvk { extent = { uint32_t(pSrcRect->right - pSrcRect->left), uint32_t(pSrcRect->bottom - pSrcRect->top), 1 }; - // TODO: Validate extents like in D3D9DeviceEx::UpdateSurface - dstOffset = { pDestPoint->x, pDestPoint->y, 0u }; - m_device->UpdateTextureFromBuffer( srcTextureInfo, dstTextureInfo, src->GetSubresource(), dst->GetSubresource(),