diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 20:06:18 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-29 20:06:18 +0000 |
commit | fdce4788af32cb9af8d77361cfddb96249263437 (patch) | |
tree | 30c6e4b04a7f46658a57a1265729e0b5ebd2de10 /chrome_frame | |
parent | 7d1025eeb76f1fe0e7bfe19f9f23b64974a63820 (diff) | |
download | chromium_src-fdce4788af32cb9af8d77361cfddb96249263437.zip chromium_src-fdce4788af32cb9af8d77361cfddb96249263437.tar.gz chromium_src-fdce4788af32cb9af8d77361cfddb96249263437.tar.bz2 |
ake string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the without-'\0' string is non-empty. This replaces the conditional code added recently that makes this case return NULL. It's easier to understand if it's simply an error to call WriteInto() in this case at all.
Add DCHECK()s or conditionals as appropriate to callers in order to ensure this assertion holds.
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/8418034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@112005 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
-rw-r--r-- | chrome_frame/chrome_tab.cc | 3 | ||||
-rw-r--r-- | chrome_frame/test/win_event_receiver.cc | 4 | ||||
-rw-r--r-- | chrome_frame/utils.cc | 1 |
3 files changed, 5 insertions, 3 deletions
diff --git a/chrome_frame/chrome_tab.cc b/chrome_frame/chrome_tab.cc index b394a11..b984e73 100644 --- a/chrome_frame/chrome_tab.cc +++ b/chrome_frame/chrome_tab.cc @@ -467,8 +467,9 @@ class SecurityDescBackup { DWORD reg_type = REG_NONE; if (backup_key.ReadValue(NULL, NULL, &len, ®_type) != ERROR_SUCCESS) return false; + DCHECK_EQ(0u, len % sizeof(wchar_t)); - if (reg_type != REG_SZ) + if ((len == 0) || (reg_type != REG_SZ)) return false; size_t wchar_count = 1 + len / sizeof(wchar_t); diff --git a/chrome_frame/test/win_event_receiver.cc b/chrome_frame/test/win_event_receiver.cc index 045a48c..fbc21f2 100644 --- a/chrome_frame/test/win_event_receiver.cc +++ b/chrome_frame/test/win_event_receiver.cc @@ -169,8 +169,8 @@ void WindowWatchdog::RemoveObserver(WindowObserver* observer) { std::string WindowWatchdog::GetWindowCaption(HWND hwnd) { std::string caption; int len = ::GetWindowTextLength(hwnd) + 1; - ::GetWindowTextA(hwnd, WriteInto(&caption, len), len); - + if (len > 1) + ::GetWindowTextA(hwnd, WriteInto(&caption, len), len); return caption; } diff --git a/chrome_frame/utils.cc b/chrome_frame/utils.cc index 7f48648..9003109 100644 --- a/chrome_frame/utils.cc +++ b/chrome_frame/utils.cc @@ -1328,6 +1328,7 @@ std::string Bscf2Str(DWORD flags) { // Reads data from a stream into a string. HRESULT ReadStream(IStream* stream, size_t size, std::string* data) { DCHECK(stream); + DCHECK_GT(size, 0u); DCHECK(data); DWORD read = 0; |