Add extra protection against invalid buffers in buffer viewer

This commit is contained in:
baldurk committed 2021-08-24 17:09:28 +01:00
1 parent f32e8525f2
commit dd8265bf9e
1 file changed
+8 -2
+8 -2
View File
@@ -2673,8 +2673,14 @@ void BufferViewer::OnEventChanged(uint32_t eventId)
rangeEnd = UINT64_MAX;
// get the underlying buffer length
uint64_t bufferLength =
m_IsBuffer && m_BufferID != ResourceId() ? m_Ctx.GetBuffer(m_BufferID)->length : 0;
uint64_t bufferLength = 0;
if(m_IsBuffer && m_BufferID != ResourceId())
{
const BufferDescription *desc = m_Ctx.GetBuffer(m_BufferID);
if(desc)
bufferLength = desc->length;
}
// clamp the range to the buffer length, which may end up with it being empty
rangeEnd = qMin(rangeEnd, bufferLength);