Don't insert wchar_t if it can't be converted to mbs

Otherwise it could hit the assertion in editBuffer while converting
to mbs for consumption by the rest of the program.

It's possibly to trigger this with LC_ALL=C and typing C-z C-v M-a,
for example.
master
C. McEnroe 2021-02-15 18:53:06 -05:00
parent a92f1260ea
commit 3b9e778dac
1 changed files with 2 additions and 0 deletions

2
edit.c
View File

@ -260,6 +260,8 @@ void edit(uint id, enum Edit op, wchar_t ch) {
}
break; case EditInsert: {
char mb[MB_LEN_MAX];
if (wctomb(mb, ch) < 0) return;
if (reserve(pos, 1)) {
buf[pos++] = ch;
}