OSDN Git Service

Don't crash when using a buffer with no data.
authorNicolas Capens <capn@google.com>
Tue, 27 Jun 2017 16:57:22 +0000 (12:57 -0400)
committerNicolas Capens <capn@google.com>
Tue, 27 Jun 2017 17:04:17 +0000 (17:04 +0000)
It's undefined behavior when an application attempts to use a buffer
for which no data has been allocated yet, but this is trivial for us to
check for and produce a non-fatal error.

Bug chromium:736639

Change-Id: I795c22363ada1b5e325d1fb5061a9e7673609879
Reviewed-on: https://swiftshader-review.googlesource.com/10309
Tested-by: Nicolas Capens <capn@google.com>
Reviewed-by: Alexis Hétu <sugoi@google.com>
src/OpenGL/libGLESv2/VertexDataManager.cpp

index 7b5cc6f..2fff628 100644 (file)
@@ -153,7 +153,7 @@ GLenum VertexDataManager::prepareVertexData(GLint start, GLsizei count, Translat
 
                                Buffer *buffer = attrib.mBoundBuffer;
 
-                               if(!buffer && attrib.mPointer == nullptr)
+                               if((!buffer && attrib.mPointer == nullptr) || (buffer && !buffer->data()))
                                {
                                        // This is an application error that would normally result in a crash, but we catch it and return an error
                                        ERR("An enabled vertex array has no buffer and no pointer.");