1
0
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:
Michael Vetter 2022-03-29 13:03:28 +02:00 committed by GitHub
commit b5a6074b31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)) {