mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-12-06 20:49:32 +00:00
demos: fix out of bounds read of instance data in D3D12_Draw_Zoo
dae198b39 grew the instance buffer from 4096 to 8192 bytes, since one
vertex buffer view binds it at an offset of 8 * sizeof(Vec4f) with a
size of 4096, but the Vec4f instData[256] array it is filled from was
left at 4096 bytes. The explicit .Size(8192) overrides the size taken
from the array, so SetBufferData copies 8192 bytes from a 4096 byte
stack array. When the read runs off the end of the stack the demo
crashes with an access violation before it renders anything.
Size the array to the buffer and let Data() take the size from it.
This commit is contained in:
1 parent
5ad608809c
commit
15110e075f
1 file changed
+2
-2
@@ -271,7 +271,7 @@ float4 main(v2f IN) : SV_Target0
|
||||
|
||||
ID3D12ResourcePtr vb = MakeBuffer().Data(vbData).Size(UINT(vbData.size() * sizeof(DefaultA2V)));
|
||||
|
||||
Vec4f instData[256] = {};
|
||||
Vec4f instData[512] = {};
|
||||
for(int i = 0; i < ARRAY_COUNT(instData); i++)
|
||||
instData[i] = Vec4f(-100.0f, -100.0f, -100.0f, -100.0f);
|
||||
|
||||
@@ -286,7 +286,7 @@ float4 main(v2f IN) : SV_Target0
|
||||
instData[14] = Vec4f(0.5f, 0.9f, 0.1f, 0.5f);
|
||||
}
|
||||
|
||||
ID3D12ResourcePtr instvb = MakeBuffer().Data(instData).Size(8192);
|
||||
ID3D12ResourcePtr instvb = MakeBuffer().Data(instData);
|
||||
|
||||
std::vector<uint16_t> idxData;
|
||||
idxData.resize(2048);
|
||||
|
||||
Reference in new issue
Block a user