readline: Don't delete input beyond a null terminator
This commit is contained in:
parent
dabbb935c5
commit
29f5316fdc
@ -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]) {
|
||||
|
Loading…
Reference in New Issue
Block a user