From ba3d230421a26ca393aa6f6778614888a701b454 Mon Sep 17 00:00:00 2001
From: Morph <39850852+Morph1984@users.noreply.github.com>
Date: Sun, 25 Jul 2021 17:12:51 -0400
Subject: [PATCH] applet_swkbd: Correct string buffer size calculation

The buffer size here does not include the initial 8 bytes.
---
 src/core/hle/service/am/applets/applet_software_keyboard.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/hle/service/am/applets/applet_software_keyboard.cpp b/src/core/hle/service/am/applets/applet_software_keyboard.cpp
index 7cae906090..673abb7552 100644
--- a/src/core/hle/service/am/applets/applet_software_keyboard.cpp
+++ b/src/core/hle/service/am/applets/applet_software_keyboard.cpp
@@ -377,7 +377,7 @@ void SoftwareKeyboard::SubmitForTextCheck(std::u16string submitted_text) {
 
     if (swkbd_config_common.use_utf8) {
         std::string utf8_submitted_text = Common::UTF16ToUTF8(current_text);
-        const u64 buffer_size = sizeof(u64) + utf8_submitted_text.size();
+        const u64 buffer_size = utf8_submitted_text.size();
 
         LOG_DEBUG(Service_AM, "\nBuffer Size: {}\nUTF-8 Submitted Text: {}", buffer_size,
                   utf8_submitted_text);
@@ -386,7 +386,7 @@ void SoftwareKeyboard::SubmitForTextCheck(std::u16string submitted_text) {
         std::memcpy(out_data.data() + sizeof(u64), utf8_submitted_text.data(),
                     utf8_submitted_text.size());
     } else {
-        const u64 buffer_size = sizeof(u64) + current_text.size() * sizeof(char16_t);
+        const u64 buffer_size = current_text.size() * sizeof(char16_t);
 
         LOG_DEBUG(Service_AM, "\nBuffer Size: {}\nUTF-16 Submitted Text: {}", buffer_size,
                   Common::UTF16ToUTF8(current_text));