Merge pull request #12694 from unknownbrackets/osk-limit

Osk: Prevent adding highlighted char past limit
This commit is contained in:
Henrik Rydgård 2020-03-09 14:46:09 +01:00 committed by GitHub
commit 94524f7893
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -658,7 +658,7 @@ std::wstring PSPOskDialog::CombinationString(bool isInput)
string += inputChars[i];
}
if (string.size() <= FieldMaxLength())
if (string.size() < FieldMaxLength())
{
string += oskKeys[currentKeyboard][selectedRow][selectedCol];
}
@ -870,7 +870,7 @@ int PSPOskDialog::NativeKeyboard() {
// Only write the bytes of the output and the null terminator, don't write the rest.
for (size_t i = 0; i < end; ++i) {
u16 value = 0;
if (i < FieldMaxLength())
if (i < FieldMaxLength() && i < inputChars.size())
value = inputChars[i];
outText[i] = value;
}
@ -1070,7 +1070,7 @@ int PSPOskDialog::Update(int animSpeed) {
for (size_t i = 0; i < end; ++i)
{
u16 value = 0;
if (i < inputChars.size())
if (i < FieldMaxLength() && i < inputChars.size())
value = inputChars[i];
outText[i] = value;
}