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

Unified Diff: src/utils/SkRTConf.cpp

Issue 22650007: Fix crash when querying a runtime config that is defined in environment (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 4 months 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
« no previous file with comments | « include/utils/SkRTConf.h ('k') | tests/UnitTestTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkRTConf.cpp
diff --git a/src/utils/SkRTConf.cpp b/src/utils/SkRTConf.cpp
index e0977fe42f21e39a21a04909610853dc0fdb9cc3..18b7ca32bbcacd52b99411f0f934ba924d40d89d 100644
--- a/src/utils/SkRTConf.cpp
+++ b/src/utils/SkRTConf.cpp
@@ -214,6 +214,7 @@ static inline void str_replace(char *s, char search, char replace) {
template<typename T> bool SkRTConfRegistry::parse(const char *name, T* value) {
SkString *str = NULL;
+ SkString tmp;
for (int i = fConfigFileKeys.count() - 1 ; i >= 0; i--) {
if (fConfigFileKeys[i]->equals(name)) {
@@ -227,6 +228,9 @@ template<typename T> bool SkRTConfRegistry::parse(const char *name, T* value) {
const char *environment_value = getenv(environment_variable.c_str());
if (environment_value) {
+ if (NULL == str) {
+ str = &tmp;
+ }
str->set(environment_value);
} else {
// apparently my shell doesn't let me have environment variables that
@@ -238,6 +242,9 @@ template<typename T> bool SkRTConfRegistry::parse(const char *name, T* value) {
sk_free(underscore_name);
environment_value = getenv(underscore_environment_variable.c_str());
if (environment_value) {
+ if (NULL == str) {
+ str = &tmp;
+ }
str->set(environment_value);
}
}
@@ -294,3 +301,18 @@ SkRTConfRegistry &skRTConfRegistry() {
static SkRTConfRegistry r;
return r;
}
+
+#ifdef SK_SUPPORT_UNITTEST
+void SkRTConfRegistry::UnitTest() {
+ SkRTConfRegistry registryWithoutContents(true);
+
+ setenv("skia_nonexistent_item", "132", 1);
+ int result = 0;
+ registryWithoutContents.parse("nonexistent.item", &result);
+ SkASSERT(result == 132);
+}
+
+SkRTConfRegistry::SkRTConfRegistry(bool)
+ : fConfs(100) {
+}
+#endif
« no previous file with comments | « include/utils/SkRTConf.h ('k') | tests/UnitTestTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698