Fix uninitialized reads in IsDefaultBrowserFirefox

BUG=
TEST=Local DrMemory.
R=tommi@webrtc.org

Review URL: https://webrtc-codereview.appspot.com/19529006

git-svn-id: http://webrtc.googlecode.com/svn/trunk@6232 4adac7df-926f-26a2-2b94-8c16560cd09d
This commit is contained in:
pbos@webrtc.org
2014-05-23 14:35:48 +00:00
parent 1566ee2893
commit 706152dcc9

View File

@@ -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;
}