From 079cc7a8dbca44368024dafa30be2280df0891d7 Mon Sep 17 00:00:00 2001 From: baldurk Date: Wed, 4 Jan 2017 16:54:33 +0000 Subject: [PATCH] Protect against invalid buffers being bound to GL * Should fix a reported crash - it looks like an invalid buffer ID was passed, and there's no protection for this. * As with other invalid API use, RenderDoc isn't intended to be totally safe against bad API use. This check is easy to add though and should catch some simple cases. --- renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp b/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp index eabadd92e..084b2ed5f 100644 --- a/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp +++ b/renderdoc/driver/gl/wrappers/gl_buffer_funcs.cpp @@ -233,6 +233,13 @@ void WrappedOpenGL::glBindBuffer(GLenum target, GLuint buffer) GLResourceRecord *r = cd.m_BufferRecord[idx] = GetResourceManager()->GetResourceRecord(BufferRes(GetCtx(), buffer)); + if(!r) + { + RDCERR("Invalid/unrecognised buffer passed: glBindBuffer(%s, %u)", ToStr::Get(target).c_str(), + buffer); + return; + } + // it's legal to re-type buffers, generate another BindBuffer chunk to rename if(r->datatype != target) {