readline: Don't delete input beyond a null terminator

This commit is contained in:
czapek1337 2022-01-29 07:54:49 +01:00 committed by mintsuki
parent dabbb935c5
commit 29f5316fdc

View File

@ -272,7 +272,6 @@ void readline(const char *orig_str, char *buf, size_t limit) {
term_autoflush = false;
size_t orig_str_len = strlen(orig_str);
memset(buf, 0, limit);
memmove(buf, orig_str, orig_str_len);
buf[orig_str_len] = 0;
@ -303,6 +302,9 @@ void readline(const char *orig_str, char *buf, size_t limit) {
cursor_back();
case GETCHAR_DELETE:;
size_t j;
if (buf[i] == 0) {
continue;
}
for (j = i; ; j++) {
buf[j] = buf[j+1];
if (!buf[j]) {