summaryrefslogtreecommitdiffstats
path: root/gpu/command_buffer/service
diff options
context:
space:
mode:
authorgman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 19:32:50 +0000
committergman@chromium.org <gman@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-11-24 19:32:50 +0000
commitabd3ee31ea51b47264986e4f5a3109582fbef97d (patch)
tree6780c5aad3a11d7e4472dba9373c7d40d756f075 /gpu/command_buffer/service
parent826fa729e3763314e75a8391af8b7ca50f3aa573 (diff)
downloadchromium_src-abd3ee31ea51b47264986e4f5a3109582fbef97d.zip
chromium_src-abd3ee31ea51b47264986e4f5a3109582fbef97d.tar.gz
chromium_src-abd3ee31ea51b47264986e4f5a3109582fbef97d.tar.bz2
Initialize destinations variables before calling GL functions
because if the context is lost those variables will be uninitialized. TEST=ran chrome, conformance tests, unit tests and hand edited gles2_demo to test BUG=none Review URL: http://codereview.chromium.org/5305005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67293 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'gpu/command_buffer/service')
-rw-r--r--gpu/command_buffer/service/common_decoder.cc11
-rw-r--r--gpu/command_buffer/service/common_decoder.h2
-rw-r--r--gpu/command_buffer/service/gles2_cmd_decoder.cc10
3 files changed, 14 insertions, 9 deletions
diff --git a/gpu/command_buffer/service/common_decoder.cc b/gpu/command_buffer/service/common_decoder.cc
index ce45422..a116d04 100644
--- a/gpu/command_buffer/service/common_decoder.cc
+++ b/gpu/command_buffer/service/common_decoder.cc
@@ -35,11 +35,16 @@ bool CommonDecoder::Bucket::SetData(
return false;
}
-void CommonDecoder::Bucket::SetFromString(const std::string& str) {
+void CommonDecoder::Bucket::SetFromString(const char* str) {
// Strings are passed NULL terminated to distinguish between empty string
// and no string.
- SetSize(str.size() + 1);
- SetData(str.c_str(), 0, str.size() + 1);
+ if (!str) {
+ SetSize(0);
+ } else {
+ size_t size = strlen(str) + 1;
+ SetSize(size);
+ SetData(str, 0, size);
+ }
}
bool CommonDecoder::Bucket::GetAsString(std::string* str) {
diff --git a/gpu/command_buffer/service/common_decoder.h b/gpu/command_buffer/service/common_decoder.h
index 7abc016..ea4e520 100644
--- a/gpu/command_buffer/service/common_decoder.h
+++ b/gpu/command_buffer/service/common_decoder.h
@@ -73,7 +73,7 @@ class CommonDecoder : public AsyncAPIInterface {
// Sets the bucket data from a string. Strings are passed NULL terminated to
// distinguish between empty string and no string.
- void SetFromString(const std::string& str);
+ void SetFromString(const char* str);
// Gets the bucket data as a string. Strings are passed NULL terminated to
// distrinquish between empty string and no string. Returns False if there
diff --git a/gpu/command_buffer/service/gles2_cmd_decoder.cc b/gpu/command_buffer/service/gles2_cmd_decoder.cc
index fbb6ca4..17d1f09 100644
--- a/gpu/command_buffer/service/gles2_cmd_decoder.cc
+++ b/gpu/command_buffer/service/gles2_cmd_decoder.cc
@@ -4313,7 +4313,7 @@ error::Error GLES2DecoderImpl::HandleGetShaderSource(
bucket->SetSize(0);
return error::kNoError;
}
- bucket->SetFromString(info->source());
+ bucket->SetFromString(info->source().c_str());
return error::kNoError;
}
@@ -4327,7 +4327,7 @@ error::Error GLES2DecoderImpl::HandleGetProgramInfoLog(
if (!info) {
return error::kNoError;
}
- bucket->SetFromString(info->log_info());
+ bucket->SetFromString(info->log_info().c_str());
return error::kNoError;
}
@@ -4342,7 +4342,7 @@ error::Error GLES2DecoderImpl::HandleGetShaderInfoLog(
bucket->SetSize(0);
return error::kNoError;
}
- bucket->SetFromString(info->log_info());
+ bucket->SetFromString(info->log_info().c_str());
return error::kNoError;
}
@@ -5739,7 +5739,7 @@ error::Error GLES2DecoderImpl::HandleGetActiveUniform(
result->size = uniform_info->size;
result->type = uniform_info->type;
Bucket* bucket = CreateBucket(name_bucket_id);
- bucket->SetFromString(uniform_info->name);
+ bucket->SetFromString(uniform_info->name.c_str());
return error::kNoError;
}
@@ -5773,7 +5773,7 @@ error::Error GLES2DecoderImpl::HandleGetActiveAttrib(
result->size = attrib_info->size;
result->type = attrib_info->type;
Bucket* bucket = CreateBucket(name_bucket_id);
- bucket->SetFromString(attrib_info->name);
+ bucket->SetFromString(attrib_info->name.c_str());
return error::kNoError;
}