diff options
author | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2017-01-03 13:44:58 +0100 |
---|---|---|
committer | ailin-nemui <ailin-nemui@users.noreply.github.com> | 2017-01-03 13:53:40 +0100 |
commit | 6c6c42e3d1b49d90aacc0b67f8540471cae02a1d (patch) | |
tree | a10c253a6b06b9758acbd5c2ff0f0b094651c1ed /src/fe-text/term-terminfo.c | |
parent | eb20a6c846373bbfba4cd80e6aef017b56409047 (diff) | |
download | irssi-6c6c42e3d1b49d90aacc0b67f8540471cae02a1d.zip |
Merge branch 'security' into 'master'
See merge request !7
Diffstat (limited to 'src/fe-text/term-terminfo.c')
-rw-r--r-- | src/fe-text/term-terminfo.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/fe-text/term-terminfo.c b/src/fe-text/term-terminfo.c index 27be904e..8fac76b3 100644 --- a/src/fe-text/term-terminfo.c +++ b/src/fe-text/term-terminfo.c @@ -539,9 +539,16 @@ int term_addstr(TERM_WINDOW *window, const char *str) if (term_type == TERM_TYPE_UTF8) { while (*ptr != '\0') { - tmp = g_utf8_get_char(ptr); - len += unichar_isprint(tmp) ? mk_wcwidth(tmp) : 1; - ptr = g_utf8_next_char(ptr); + tmp = g_utf8_get_char_validated(ptr, -1); + /* On utf8 error, treat as single byte and try to + continue interpretting rest of string as utf8 */ + if (tmp == (gunichar)-1 || tmp == (gunichar)-2) { + len++; + ptr++; + } else { + len += unichar_isprint(tmp) ? mk_wcwidth(tmp) : 1; + ptr = g_utf8_next_char(ptr); + } } } else len = raw_len; |