summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Morph2021-05-27 23:13:39 -0400
committerGravatar Morph2021-05-27 23:45:56 -0400
commit247cd92216160dd020464d57a28aa3c1ce731095 (patch)
tree11ac756abd08444b023e9a4432fe81543459f2b3 /src
parentMerge pull request #6372 from bunnei/raster-cache-fix (diff)
downloadyuzu-247cd92216160dd020464d57a28aa3c1ce731095.tar.gz
yuzu-247cd92216160dd020464d57a28aa3c1ce731095.tar.xz
yuzu-247cd92216160dd020464d57a28aa3c1ce731095.zip
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.
Diffstat (limited to 'src')
-rw-r--r--src/core/hle/service/am/applets/software_keyboard.cpp9
1 files changed, 7 insertions, 2 deletions
diff --git a/src/core/hle/service/am/applets/software_keyboard.cpp b/src/core/hle/service/am/applets/software_keyboard.cpp
index b05a5da04..a1027a9ad 100644
--- a/src/core/hle/service/am/applets/software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/software_keyboard.cpp
@@ -273,8 +273,13 @@ void SoftwareKeyboard::ProcessTextCheck() {
273 273
274 std::memcpy(&swkbd_text_check, text_check_data.data(), sizeof(SwkbdTextCheck)); 274 std::memcpy(&swkbd_text_check, text_check_data.data(), sizeof(SwkbdTextCheck));
275 275
276 std::u16string text_check_message = Common::UTF16StringFromFixedZeroTerminatedBuffer( 276 std::u16string text_check_message =
277 swkbd_text_check.text_check_message.data(), swkbd_text_check.text_check_message.size()); 277 swkbd_text_check.text_check_result == SwkbdTextCheckResult::Failure ||
278 swkbd_text_check.text_check_result == SwkbdTextCheckResult::Confirm
279 ? Common::UTF16StringFromFixedZeroTerminatedBuffer(
280 swkbd_text_check.text_check_message.data(),
281 swkbd_text_check.text_check_message.size())
282 : u"";
278 283
279 LOG_INFO(Service_AM, "\nTextCheckResult: {}\nTextCheckMessage: {}", 284 LOG_INFO(Service_AM, "\nTextCheckResult: {}\nTextCheckMessage: {}",
280 GetTextCheckResultName(swkbd_text_check.text_check_result), 285 GetTextCheckResultName(swkbd_text_check.text_check_result),