summaryrefslogtreecommitdiffstats
path: root/views
diff options
context:
space:
mode:
authorcbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-18 15:44:59 +0000
committercbentzel@chromium.org <cbentzel@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-10-18 15:44:59 +0000
commit11fe41a6b2cb4229f8ef3ff0bc22fd609fe838e4 (patch)
tree4d96de4a5d645b319425b2864f4d5700e39c0642 /views
parenta2d67740c562caea523f3650c063d75ee4c0a8ac (diff)
downloadchromium_src-11fe41a6b2cb4229f8ef3ff0bc22fd609fe838e4.zip
chromium_src-11fe41a6b2cb4229f8ef3ff0bc22fd609fe838e4.tar.gz
chromium_src-11fe41a6b2cb4229f8ef3ff0bc22fd609fe838e4.tar.bz2
WriteInto handles length_with_null values of 1 better.
In debug builds on VS2010, the old code triggered a debug assertion in xstring, since [0] was being accessed and the size of the array was 0. A |length_with_null| of 1 is considered a valid use of this function, so an alternate implementation is used which returns the data() pointer. BUG=None TEST=net_unittests --gtest_filter=*Digest* on debug on VS2010 works. Review URL: http://codereview.chromium.org/8143001 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@106062 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'views')
-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;
}