Skip to content

Commit

Permalink
Update memcpy for InputBuffer::Upload to limit size of copy to a vali…
Browse files Browse the repository at this point in the history
…d data range

We've seen at least one app that appears to be passing too high of a
vertex count. This should guard against reading out of bounds.
  • Loading branch information
vdwtanner committed Nov 30, 2023
1 parent 3f33067 commit 4122c96
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/9on12InputAssembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ namespace D3D9on12

m_tempGPUBuffer = device.GetSystemMemoryAllocator().Allocate(drawOffset + drawSize);

memcpy((byte*)m_tempGPUBuffer.m_pMappedAddress + drawOffset, (byte*)GetSystemMemoryBase() + drawOffset, drawSize);
UINT32 maxCopySize = m_sizeInBytes - drawOffset;
memcpy((byte*)m_tempGPUBuffer.m_pMappedAddress + drawOffset, (byte*)GetSystemMemoryBase() + drawOffset, min(drawSize, maxCopySize));

return S_OK;
}
Expand Down

0 comments on commit 4122c96

Please sign in to comment.