From dd8265bf9edc7499201506055452559351fad3f4 Mon Sep 17 00:00:00 2001 From: baldurk Date: Tue, 24 Aug 2021 17:09:20 +0100 Subject: [PATCH] Add extra protection against invalid buffers in buffer viewer --- qrenderdoc/Windows/BufferViewer.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/qrenderdoc/Windows/BufferViewer.cpp b/qrenderdoc/Windows/BufferViewer.cpp index cd4905513..28259f3c4 100644 --- a/qrenderdoc/Windows/BufferViewer.cpp +++ b/qrenderdoc/Windows/BufferViewer.cpp @@ -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);