about summary refs log tree commit diff
path: root/edit.c
diff options
context:
space:
mode:
authorJune McEnroe <june@causal.agency>2021-02-15 18:53:06 -0500
committerJune McEnroe <june@causal.agency>2021-02-15 19:15:38 -0500
commit3b9e778dacd3392fdf2e8fc29e726b401b50abfe (patch)
treea24ce0c471586eae197090239fba7f3b3535a712 /edit.c
parentDon't expand macro if it can't be converted to mbs (diff)
downloadcatgirl-3b9e778dacd3392fdf2e8fc29e726b401b50abfe.tar.gz
catgirl-3b9e778dacd3392fdf2e8fc29e726b401b50abfe.zip
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.
Diffstat (limited to '')
-rw-r--r--edit.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/edit.c b/edit.c
index fc23c58..3e7e1af 100644
--- a/edit.c
+++ b/edit.c
@@ -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;
 			}
1/hi.1?id=bc2eb7a5313217c2edf32914c5018ed910d08b15&follow=1'>Add hi -f html -o anchor for line number linksJune McEnroe 2019-02-17Simplify temp trap in upJune McEnroe 2019-02-17Add line numbers to hiJune McEnroe 2019-02-17Always split spans after newlinesJune McEnroe 2019-02-15Color format specifiers light cyan in vimJune McEnroe 2019-02-15Highlight Interp as yellowJune McEnroe 2019-02-15Highlight strings in sh command substitutionsJune McEnroe 2019-02-15Add nmap gpJune McEnroe 2019-02-14Avoid newline when copying URL to pasteboardJune McEnroe 2019-02-13Add forgotten "sixth" book of H2G2June McEnroe