summaryrefslogtreecommitdiffstats
path: root/chromium/third_party/libjingle/source/talk/base/proxydetect.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/libjingle/source/talk/base/proxydetect.cc')
-rw-r--r--chromium/third_party/libjingle/source/talk/base/proxydetect.cc30
1 files changed, 15 insertions, 15 deletions
diff --git a/chromium/third_party/libjingle/source/talk/base/proxydetect.cc b/chromium/third_party/libjingle/source/talk/base/proxydetect.cc
index 7292f3b9fd2..8f7f7f87260 100644
--- a/chromium/third_party/libjingle/source/talk/base/proxydetect.cc
+++ b/chromium/third_party/libjingle/source/talk/base/proxydetect.cc
@@ -638,27 +638,27 @@ bool IsDefaultBrowserFirefox() {
if (ERROR_SUCCESS != result)
return false;
- wchar_t* value = NULL;
DWORD size, type;
+ bool success = false;
result = RegQueryValueEx(key, L"", 0, &type, NULL, &size);
- if (REG_SZ != type) {
- result = ERROR_ACCESS_DENIED; // Any error is fine
- } else if (ERROR_SUCCESS == result) {
- value = new wchar_t[size+1];
+ if (result == ERROR_SUCCESS && type == REG_SZ) {
+ wchar_t* value = new wchar_t[size+1];
BYTE* buffer = reinterpret_cast<BYTE*>(value);
result = RegQueryValueEx(key, L"", 0, &type, buffer, &size);
- }
- RegCloseKey(key);
-
- bool success = false;
- if (ERROR_SUCCESS == result) {
- value[size] = L'\0';
- for (size_t i = 0; i < size; ++i) {
- value[i] = tolowercase(value[i]);
+ if (result == ERROR_SUCCESS) {
+ // Size returned by RegQueryValueEx is in bytes, convert to number of
+ // wchar_t's.
+ size /= sizeof(value[0]);
+ value[size] = L'\0';
+ for (size_t i = 0; i < size; ++i) {
+ value[i] = tolowercase(value[i]);
+ }
+ success = (NULL != strstr(value, L"firefox.exe"));
}
- success = (NULL != strstr(value, L"firefox.exe"));
+ delete[] value;
}
- delete [] value;
+
+ RegCloseKey(key);
return success;
}