mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-10-12 23:29:26 +00:00
Make sure glGetBufferSubData call doesn't overrun buffer size
This commit is contained in:
1 parent
3fa9dcdf47
commit
5ae4b0d649
1 file changed
+8
-2
@@ -274,17 +274,23 @@ vector<byte> GLReplay::GetBufferData(ResourceId buff, uint32_t offset, uint32_t
|
||||
}
|
||||
|
||||
auto &buf = m_pDriver->m_Buffers[buff];
|
||||
|
||||
uint32_t bufsize = (uint32_t)buf.size;
|
||||
|
||||
if(len > 0 && offset+len > buf.size)
|
||||
{
|
||||
RDCWARN("Attempting to read off the end of the array. Will be clamped");
|
||||
len = RDCMIN(len, uint32_t(buf.size-offset));
|
||||
len = ~0U; // min below will clamp to max size size
|
||||
}
|
||||
else if(len == 0)
|
||||
{
|
||||
len = (uint32_t)buf.size;
|
||||
len = bufsize;
|
||||
}
|
||||
|
||||
// need to ensure len+offset doesn't overrun buffer or the glGetBufferSubData call
|
||||
// will fail.
|
||||
len = RDCMIN(len, bufsize-offset);
|
||||
|
||||
ret.resize(len);
|
||||
|
||||
WrappedOpenGL &gl = *m_pDriver;
|
||||
|
||||
Reference in new issue
Block a user