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

Side by Side Diff: gpu/command_buffer/service/gles2_cmd_decoder.cc

Issue 8404029: Strip comments from shader before checking for invalid characters (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 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
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "gpu/command_buffer/service/gles2_cmd_decoder.h" 5 #include "gpu/command_buffer/service/gles2_cmd_decoder.h"
6 6
7 #include <stdio.h> 7 #include <stdio.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <list> 10 #include <list>
(...skipping 4730 matching lines...) Expand 10 before | Expand all | Expand 10 after
4741 return max_vertex_accessed; 4741 return max_vertex_accessed;
4742 } 4742 }
4743 4743
4744 // Calls glShaderSource for the various versions of the ShaderSource command. 4744 // Calls glShaderSource for the various versions of the ShaderSource command.
4745 // Assumes that data / data_size points to a piece of memory that is in range 4745 // Assumes that data / data_size points to a piece of memory that is in range
4746 // of whatever context it came from (shared memory, immediate memory, bucket 4746 // of whatever context it came from (shared memory, immediate memory, bucket
4747 // memory.) 4747 // memory.)
4748 error::Error GLES2DecoderImpl::ShaderSourceHelper( 4748 error::Error GLES2DecoderImpl::ShaderSourceHelper(
4749 GLuint client_id, const char* data, uint32 data_size) { 4749 GLuint client_id, const char* data, uint32 data_size) {
4750 std::string str(data, data + data_size); 4750 std::string str(data, data + data_size);
4751 if (!StringIsValidForGLES(str.c_str())) { 4751 std::string stripped = ShaderManager::StripComments(str);
4752 if (!StringIsValidForGLES(stripped.c_str())) {
4752 SetGLError(GL_INVALID_VALUE, "glShaderSource: Invalid character"); 4753 SetGLError(GL_INVALID_VALUE, "glShaderSource: Invalid character");
4753 return error::kNoError; 4754 return error::kNoError;
4754 } 4755 }
4755 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram( 4756 ShaderManager::ShaderInfo* info = GetShaderInfoNotProgram(
4756 client_id, "glShaderSource"); 4757 client_id, "glShaderSource");
4757 if (!info) { 4758 if (!info) {
4758 return error::kNoError; 4759 return error::kNoError;
4759 } 4760 }
4760 // Note: We don't actually call glShaderSource here. We wait until 4761 // Note: We don't actually call glShaderSource here. We wait until
4761 // the call to glCompileShader. 4762 // the call to glCompileShader.
4762 info->UpdateSource(str.c_str()); 4763 info->UpdateSource(str.c_str());
jbauman 2011/10/27 18:02:01 Actually, if we're worried about unusual character
4763 return error::kNoError; 4764 return error::kNoError;
4764 } 4765 }
4765 4766
4766 error::Error GLES2DecoderImpl::HandleShaderSource( 4767 error::Error GLES2DecoderImpl::HandleShaderSource(
4767 uint32 immediate_data_size, const gles2::ShaderSource& c) { 4768 uint32 immediate_data_size, const gles2::ShaderSource& c) {
4768 uint32 data_size = c.data_size; 4769 uint32 data_size = c.data_size;
4769 const char* data = GetSharedMemoryAs<const char*>( 4770 const char* data = GetSharedMemoryAs<const char*>(
4770 c.data_shm_id, c.data_shm_offset, data_size); 4771 c.data_shm_id, c.data_shm_offset, data_size);
4771 if (!data) { 4772 if (!data) {
4772 return error::kOutOfBounds; 4773 return error::kOutOfBounds;
(...skipping 2432 matching lines...) Expand 10 before | Expand all | Expand 10 after
7205 return error::kNoError; 7206 return error::kNoError;
7206 } 7207 }
7207 7208
7208 // Include the auto-generated part of this file. We split this because it means 7209 // Include the auto-generated part of this file. We split this because it means
7209 // we can easily edit the non-auto generated parts right here in this file 7210 // we can easily edit the non-auto generated parts right here in this file
7210 // instead of having to edit some template or the code generator. 7211 // instead of having to edit some template or the code generator.
7211 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h" 7212 #include "gpu/command_buffer/service/gles2_cmd_decoder_autogen.h"
7212 7213
7213 } // namespace gles2 7214 } // namespace gles2
7214 } // namespace gpu 7215 } // namespace gpu
OLDNEW
« no previous file with comments | « no previous file | gpu/command_buffer/service/gles2_cmd_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698