summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/automation/testing_automation_provider_win.cc7
-rw-r--r--chrome/browser/browser_focus_uitest.cc7
-rw-r--r--chrome/browser/mac/install_from_dmg.mm4
-rw-r--r--chrome/browser/ui/views/omnibox/omnibox_view_win.cc14
4 files changed, 16 insertions, 16 deletions
diff --git a/chrome/browser/automation/testing_automation_provider_win.cc b/chrome/browser/automation/testing_automation_provider_win.cc
index 424aa39..21d2137 100644
--- a/chrome/browser/automation/testing_automation_provider_win.cc
+++ b/chrome/browser/automation/testing_automation_provider_win.cc
@@ -86,9 +86,10 @@ void TestingAutomationProvider::SetWindowVisible(int handle,
void TestingAutomationProvider::GetWindowTitle(int handle, string16* text) {
gfx::NativeWindow window = window_tracker_->GetResource(handle);
- std::wstring result;
int length = ::GetWindowTextLength(window) + 1;
- ::GetWindowText(window, WriteInto(&result, length), length);
- text->assign(WideToUTF16(result));
+ if (length > 1)
+ ::GetWindowText(window, WriteInto(text, length), length);
+ else
+ text->clear();
}
diff --git a/chrome/browser/browser_focus_uitest.cc b/chrome/browser/browser_focus_uitest.cc
index 0f4fdcc..dada7af 100644
--- a/chrome/browser/browser_focus_uitest.cc
+++ b/chrome/browser/browser_focus_uitest.cc
@@ -90,7 +90,8 @@ bool ChromeInForeground() {
std::wstring caption;
std::wstring filename;
int len = ::GetWindowTextLength(window) + 1;
- ::GetWindowText(window, WriteInto(&caption, len), len);
+ if (len > 1)
+ ::GetWindowText(window, WriteInto(&caption, len), len);
bool chrome_window_in_foreground =
EndsWith(caption, L" - Google Chrome", true) ||
EndsWith(caption, L" - Chromium", true);
@@ -102,8 +103,8 @@ bool ChromeInForeground() {
if (base::OpenProcessHandleWithAccess(process_id,
PROCESS_QUERY_LIMITED_INFORMATION,
&process)) {
- len = MAX_PATH;
- if (!GetProcessImageFileName(process, WriteInto(&filename, len), len)) {
+ if (!GetProcessImageFileName(process, WriteInto(&filename, MAX_PATH),
+ MAX_PATH)) {
int error = GetLastError();
filename = std::wstring(L"Unable to read filename for process id '" +
base::IntToString16(process_id) +
diff --git a/chrome/browser/mac/install_from_dmg.mm b/chrome/browser/mac/install_from_dmg.mm
index b263491..6f276b8 100644
--- a/chrome/browser/mac/install_from_dmg.mm
+++ b/chrome/browser/mac/install_from_dmg.mm
@@ -141,6 +141,10 @@ bool MediaResidesOnDiskImage(io_service_t media, std::string* image_path) {
CFDataRef image_path_data = static_cast<CFDataRef>(
image_path_cftyperef.get());
CFIndex length = CFDataGetLength(image_path_data);
+ if (length <= 0) {
+ LOG(ERROR) << "image_path_data is unexpectedly empty";
+ return true;
+ }
char* image_path_c = WriteInto(image_path, length + 1);
CFDataGetBytes(image_path_data,
CFRangeMake(0, length),
diff --git a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
index fd0ca98..379d94d 100644
--- a/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
+++ b/chrome/browser/ui/views/omnibox/omnibox_view_win.cc
@@ -645,11 +645,9 @@ void OmniboxViewWin::OpenMatch(const AutocompleteMatch& match,
string16 OmniboxViewWin::GetText() const {
const int len = GetTextLength() + 1;
- if (len <= 1)
- return string16();
-
string16 str;
- GetWindowText(WriteInto(&str, len), len);
+ if (len > 1)
+ GetWindowText(WriteInto(&str, len), len);
return str;
}
@@ -2128,15 +2126,11 @@ void OmniboxViewWin::GetSelection(CHARRANGE& sel) const {
}
string16 OmniboxViewWin::GetSelectedText() const {
- // Figure out the length of the selection.
CHARRANGE sel;
GetSel(sel);
- if (sel.cpMin == sel.cpMax) // GetSelText() crashes on NULL input.
- return string16();
-
- // Grab the selected text.
string16 str;
- GetSelText(WriteInto(&str, sel.cpMax - sel.cpMin + 1));
+ if (sel.cpMin != sel.cpMax)
+ GetSelText(WriteInto(&str, sel.cpMax - sel.cpMin + 1));
return str;
}