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

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, 1 month 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
« no previous file with comments | « ui/base/l10n/l10n_util.cc ('k') | views/controls/textfield/native_textfield_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/base/win/ime_input.cc
===================================================================
--- ui/base/win/ime_input.cc (revision 111826)
+++ 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))
+ 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) {
« no previous file with comments | « ui/base/l10n/l10n_util.cc ('k') | views/controls/textfield/native_textfield_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698