diff options
author | nicm <nicm> | 2016-03-02 15:36:02 +0000 |
---|---|---|
committer | nicm <nicm> | 2016-03-02 15:36:02 +0000 |
commit | b8a102d26f41e57b94359627a4df8f22af10c6fa (patch) | |
tree | 43730f925370a2d77bf64e817cb77bfaf4849dc5 /input.c | |
parent | d980d965ddb6165bd801351892fed2497204a279 (diff) | |
download | rtmux-b8a102d26f41e57b94359627a4df8f22af10c6fa.tar.gz rtmux-b8a102d26f41e57b94359627a4df8f22af10c6fa.tar.bz2 rtmux-b8a102d26f41e57b94359627a4df8f22af10c6fa.zip |
Handle wcwidth() and mbtowc() failures in better style and drop
characters where we can't find the width (wcwidth() fails) on input, the
same as we drop invalid UTF-8. Suggested by schwarze@.
Diffstat (limited to 'input.c')
-rw-r--r-- | input.c | 10 |
1 files changed, 8 insertions, 2 deletions
@@ -1960,8 +1960,14 @@ input_utf8_close(struct input_ctx *ictx) { struct utf8_data *ud = &ictx->utf8data; - if (utf8_append(ud, ictx->ch) != UTF8_DONE) - fatalx("UTF-8 close invalid %#x", ictx->ch); + if (utf8_append(ud, ictx->ch) != UTF8_DONE) { + /* + * An error here could be invalid UTF-8 or it could be a + * nonprintable character for which we can't get the + * width. Drop it. + */ + return (0); + } log_debug("%s %hhu '%*s' (width %hhu)", __func__, ud->size, (int)ud->size, ud->data, ud->width); |