mirror of
https://github.com/profanity-im/profanity.git
synced 2025-01-03 14:57:42 -05:00
Merge pull request #1660 from paulfertser/fix-invalid-mbrlen-input
Input window: handle invalid multibyte
This commit is contained in:
commit
b5a6074b31
@ -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