Chromium Code Reviews| Index: gpu/command_buffer/client/gles2_c_lib.cc |
| =================================================================== |
| --- gpu/command_buffer/client/gles2_c_lib.cc (revision 67161) |
| +++ gpu/command_buffer/client/gles2_c_lib.cc (working copy) |
| @@ -4,8 +4,35 @@ |
| // These functions emluate GLES2 over command buffers for C. |
| +#include <assert.h> |
| #include "../client/gles2_lib.h" |
| +// Check that destination pointers point to initialized memory. |
| +// When the context is lost, calling GL function has no effect so if destination |
| +// pointers point to initialized memory it can often lead to crash bugs. eg. |
| +// |
| +// GLsizei len; |
| +// glGetShaderSource(shader, max_size, &len, buffer); |
| +// std::string src(buffer, buffer + len); // len can be uninitialized here!!! |
| +// |
| +// Because this is check is not official GL this check happens only on Chrome |
|
apatrick
2010/11/24 18:13:04
this is check -> this check
|
| +// code, not Pepper. |
| +// |
| +// If it was up to us we'd just always write to the destination but the OpenGL |
| +// spec defines the behavior of OpenGL function, not us. :-( |
| +#if defined(GPU_DCHECK) |
| +#define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(ptr) \ |
| + GPU_DCHECK(ptr && (ptr[0] == 0 || ptr[0] == -1)); |
| +#elif defined(DCHECK) |
| +#define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(ptr) \ |
| + DCHECK(ptr && (ptr[0] == 0 || ptr[0] == -1)); |
| +#elif !defined(__native_client__) |
| +#define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(ptr) \ |
| + assert(ptr && (ptr[0] == 0 || ptr[0] == -1)); |
| +#else |
| +#define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(ptr) |
| +#endif |
| + |
| extern "C" { |
| // Include the auto-generated part of this file. We split this because it means |
| // we can easily edit the non-auto generated parts right here in this file |