From ccb8531ce663f8d3cd6cbddf15284855dc75bf91 Mon Sep 17 00:00:00 2001 From: d0k3 Date: Tue, 18 Jun 2019 01:07:21 +0200 Subject: [PATCH] swkbd: Fix deleting the last char in a string --- arm9/source/common/swkbd.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arm9/source/common/swkbd.c b/arm9/source/common/swkbd.c index ce58b54..5ef3b36 100644 --- a/arm9/source/common/swkbd.c +++ b/arm9/source/common/swkbd.c @@ -281,9 +281,11 @@ bool ShowKeyboard(char* inputstr, const u32 max_size, const char *format, ...) { break; } else if (key == KEY_BKSPC) { if (cursor) { - memmove(inputstr + cursor - 1, inputstr + cursor, max_size - cursor); + if (cursor <= inputstr_size) { + memmove(inputstr + cursor - 1, inputstr + cursor, inputstr_size - cursor + 1); + inputstr_size--; + } cursor--; - inputstr_size--; } } else if (key == KEY_LEFT) { if (cursor) cursor--;