summaryrefslogtreecommitdiffstats
path: root/views/controls/textfield/native_textfield_win.cc
diff options
context:
space:
mode:
Diffstat (limited to 'views/controls/textfield/native_textfield_win.cc')
-rw-r--r--views/controls/textfield/native_textfield_win.cc6
1 files changed, 4 insertions, 2 deletions
diff --git a/views/controls/textfield/native_textfield_win.cc b/views/controls/textfield/native_textfield_win.cc
index 8e29ebc..6001674 100644
--- a/views/controls/textfield/native_textfield_win.cc
+++ b/views/controls/textfield/native_textfield_win.cc
@@ -209,8 +209,10 @@ string16 NativeTextfieldWin::GetSelectedText() const {
GetSel(start, end);
// Grab the selected text.
- std::wstring str;
- GetSelText(WriteInto(&str, end - start + 1));
+ string16 str;
+ long length = end - start;
+ if (length > 0)
+ GetSelText(WriteInto(&str, length + 1));
return str;
}