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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // These functions emluate GLES2 over command buffers for C. 5 // These functions emluate GLES2 over command buffers for C.
6 6
7 #include <assert.h>
7 #include "../client/gles2_lib.h" 8 #include "../client/gles2_lib.h"
8 9
10 // Check that destination pointers point to initialized memory.
11 // When the context is lost, calling GL function has no effect so if destination
12 // pointers point to initialized memory it can often lead to crash bugs. eg.
13 //
14 // GLsizei len;
15 // glGetShaderSource(shader, max_size, &len, buffer);
16 // std::string src(buffer, buffer + len); // len can be uninitialized here!!!
17 //
18 // 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
19 // code, not Pepper.
20 //
21 // If it was up to us we'd just always write to the destination but the OpenGL
22 // spec defines the behavior of OpenGL function, not us. :-(
23 #if defined(GPU_DCHECK)
24 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(ptr) \
25 GPU_DCHECK(ptr && (ptr[0] == 0 || ptr[0] == -1));
26 #elif defined(DCHECK)
27 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(ptr) \
28 DCHECK(ptr && (ptr[0] == 0 || ptr[0] == -1));
29 #elif !defined(__native_client__)
30 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(ptr) \
31 assert(ptr && (ptr[0] == 0 || ptr[0] == -1));
32 #else
33 #define GL_CLIENT_VALIDATE_DESTINATION_INITALIZATION(ptr)
34 #endif
35
9 extern "C" { 36 extern "C" {
10 // Include the auto-generated part of this file. We split this because it means 37 // Include the auto-generated part of this file. We split this because it means
11 // we can easily edit the non-auto generated parts right here in this file 38 // we can easily edit the non-auto generated parts right here in this file
12 // instead of having to edit some template or the code generator. 39 // instead of having to edit some template or the code generator.
13 #include "../client/gles2_c_lib_autogen.h" 40 #include "../client/gles2_c_lib_autogen.h"
14 } // extern "C" 41 } // extern "C"
15 42
16 43
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698