mirror of
https://github.com/profanity-im/profanity.git
synced 2025-02-02 15:08:15 -05:00
Input window: handle invalid multibyte
The current code enters an infinite loop if the input string happens
to get an invalid utf-8 sequence somehow. For me it was reproducible
by running profanity in a Screen session and pressing Alt-т (cyrillic
letter).
Fix it the way borrowed from 0501e49623
where mbrlen is used for the same purposes.
This commit is contained in:
parent
3ee3d78af5
commit
1e81eea899
@ -373,6 +373,10 @@ _inp_offset_to_col(char* str, int offset)
|
||||
while (i < offset && str[i] != '\0') {
|
||||
gunichar uni = g_utf8_get_char(&str[i]);
|
||||
size_t ch_len = mbrlen(&str[i], MB_CUR_MAX, NULL);
|
||||
if ((ch_len == (size_t)-2) || (ch_len == (size_t)-1)) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
i += ch_len;
|
||||
col++;
|
||||
if (g_unichar_iswide(uni)) {
|
||||
|
Loading…
Reference in New Issue
Block a user