mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-11-25 12:56:27 -05:00
applets/swkbd: Only read the text check message on Failure/Confirm
Applications may leave this region of memory uninitialized when the text check result is not either Failure or Confirm. Attempting to read uninitialized memory may cause an exception within the UTF16 to UTF8 string converter. Fix this by only reading the text check message on Failure or Confirm.
This commit is contained in:
parent
3289abe1cc
commit
247cd92216
1 changed files with 7 additions and 2 deletions
|
@ -273,8 +273,13 @@ void SoftwareKeyboard::ProcessTextCheck() {
|
|||
|
||||
std::memcpy(&swkbd_text_check, text_check_data.data(), sizeof(SwkbdTextCheck));
|
||||
|
||||
std::u16string text_check_message = Common::UTF16StringFromFixedZeroTerminatedBuffer(
|
||||
swkbd_text_check.text_check_message.data(), swkbd_text_check.text_check_message.size());
|
||||
std::u16string text_check_message =
|
||||
swkbd_text_check.text_check_result == SwkbdTextCheckResult::Failure ||
|
||||
swkbd_text_check.text_check_result == SwkbdTextCheckResult::Confirm
|
||||
? Common::UTF16StringFromFixedZeroTerminatedBuffer(
|
||||
swkbd_text_check.text_check_message.data(),
|
||||
swkbd_text_check.text_check_message.size())
|
||||
: u"";
|
||||
|
||||
LOG_INFO(Service_AM, "\nTextCheckResult: {}\nTextCheckMessage: {}",
|
||||
GetTextCheckResultName(swkbd_text_check.text_check_result),
|
||||
|
|
Loading…
Reference in a new issue