Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(134)

Unified Diff: gpu/command_buffer/client/gles2_c_lib.cc

Issue 5305005: Initialize destinations variables before calling GL functions... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 10 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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

Powered by Google App Engine
This is Rietveld 408576698