summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
Diffstat (limited to 'chrome')
-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
-rw-r--r--chrome/common/metrics_log_manager.cc2
-rw-r--r--chrome/common/time_format.cc4
6 files changed, 19 insertions, 19 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;
}
diff --git a/chrome/common/metrics_log_manager.cc b/chrome/common/metrics_log_manager.cc
index 37a9e4b..960672a 100644
--- a/chrome/common/metrics_log_manager.cc
+++ b/chrome/common/metrics_log_manager.cc
@@ -105,7 +105,7 @@ void MetricsLogManager::LoadPersistedUnsentLogs() {
void MetricsLogManager::CompressStagedLog() {
int text_size = staged_log_->GetEncodedLogSize();
std::string staged_log_text;
- // Leave room for the NULL terminator.
+ DCHECK_GT(text_size, 0);
staged_log_->GetEncodedLog(WriteInto(&staged_log_text, text_size + 1),
text_size);
diff --git a/chrome/common/time_format.cc b/chrome/common/time_format.cc
index 75407a9..c4cf9ca 100644
--- a/chrome/common/time_format.cc
+++ b/chrome/common/time_format.cc
@@ -296,9 +296,9 @@ static string16 FormatTimeImpl(const TimeDelta& delta, FormatType format_type) {
// With the fallback added, this should never fail.
DCHECK(U_SUCCESS(error));
int capacity = time_string.length() + 1;
+ DCHECK_GT(capacity, 1);
string16 result;
- time_string.extract(static_cast<UChar*>(
- WriteInto(&result, capacity)),
+ time_string.extract(static_cast<UChar*>(WriteInto(&result, capacity)),
capacity, error);
DCHECK(U_SUCCESS(error));
return result;