Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(952)

Unified Diff: ui/base/win/ime_input.cc

Issue 8418034: Make string_util::WriteInto() DCHECK() that the supplied |length_with_null| > 1, meaning that the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: ui/base/win/ime_input.cc
===================================================================
--- ui/base/win/ime_input.cc (revision 107404)
+++ ui/base/win/ime_input.cc (working copy)
@@ -339,22 +339,19 @@
}
}
-bool ImeInput::GetString(HIMC imm_context, WPARAM lparam, int type,
+bool ImeInput::GetString(HIMC imm_context,
+ WPARAM lparam,
+ int type,
string16* result) {
- bool ret = false;
- if (lparam & type) {
- int string_size = ::ImmGetCompositionString(imm_context, type, NULL, 0);
- if (string_size > 0) {
- int string_length = string_size / sizeof(wchar_t);
- wchar_t *string_data = WriteInto(result, string_length + 1);
- if (string_data) {
- // Fill the given result object.
- ::ImmGetCompositionString(imm_context, type, string_data, string_size);
- ret = true;
- }
- }
- }
- return ret;
+ if (!lparam || !type)
cbentzel 2011/11/01 12:15:07 This isn't the same logic as before - intentional?
Peter Kasting 2011/11/01 19:43:28 Nice catch! I misread "&" as "&&".
+ return false;
+ LONG string_size = ::ImmGetCompositionString(imm_context, type, NULL, 0);
+ if (string_size <= 0)
+ return false;
+ DCHECK_EQ(0u, string_size % sizeof(wchar_t));
+ ::ImmGetCompositionString(imm_context, type,
+ WriteInto(result, (string_size / sizeof(wchar_t)) + 1), string_size);
+ return true;
}
bool ImeInput::GetResult(HWND window_handle, LPARAM lparam, string16* result) {

Powered by Google App Engine
This is Rietveld 408576698