mirror of
https://codeberg.org/dnkl/foot.git
synced 2026-02-05 04:06:08 -05:00
vt: bug: fix check for error from mbrtowc()
mbrtowc() returns an unsigned. Need to cast to signed before checking if less than zero. This fixes an issue where invalid utf-8 sequences where treated as valid.
This commit is contained in:
parent
51f8453f9d
commit
75b8fc52b8
1 changed files with 4 additions and 1 deletions
5
vt.c
5
vt.c
|
|
@ -474,7 +474,10 @@ action_utf8_print(struct terminal *term, uint8_t c)
|
|||
/* Convert to wchar */
|
||||
mbstate_t ps = {0};
|
||||
wchar_t wc;
|
||||
if (mbrtowc(&wc, (const char *)term->vt.utf8.data, term->vt.utf8.idx, &ps) < 0)
|
||||
size_t count = mbrtowc(
|
||||
&wc, (const char *)term->vt.utf8.data, term->vt.utf8.idx, &ps);
|
||||
|
||||
if ((ssize_t)count < 0)
|
||||
wc = 0;
|
||||
|
||||
/* Reset VT utf8 state */
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue