0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.0.1467: libvterm doesn't handle illegal byte sequence correctly

Problem:    Libvterm doesn't handle illegal byte sequence correctly.
Solution:   After the invalid code check if there is space to store another
            character.  Allocate one more character. (zhykzhykzhyk, closes
            #2614, closes #2613)
This commit is contained in:
Bram Moolenaar
2018-02-04 14:49:57 +01:00
parent 06b77ef69f
commit fef4ddd5eb
3 changed files with 10 additions and 5 deletions

View File

@@ -46,14 +46,16 @@ static void decode_utf8(VTermEncoding *enc UNUSED, void *data_,
return; return;
else if(c >= 0x20 && c < 0x7f) { else if(c >= 0x20 && c < 0x7f) {
if(data->bytes_remaining) if(data->bytes_remaining) {
data->bytes_remaining = 0;
cp[(*cpi)++] = UNICODE_INVALID; cp[(*cpi)++] = UNICODE_INVALID;
if (*cpi >= cplen)
break;
}
cp[(*cpi)++] = c; cp[(*cpi)++] = c;
#ifdef DEBUG_PRINT_UTF8 #ifdef DEBUG_PRINT_UTF8
printf(" UTF-8 char: U+%04x\n", c); printf(" UTF-8 char: U+%04x\n", c);
#endif #endif
data->bytes_remaining = 0;
} }
else if(c == 0x7f) /* DEL */ else if(c == 0x7f) /* DEL */

View File

@@ -248,8 +248,9 @@ static int on_text(const char bytes[], size_t len, void *user)
VTermPos oldpos = state->pos; VTermPos oldpos = state->pos;
/* We'll have at most len codepoints */ /* We'll have at most len codepoints, plus one from a previous incomplete
codepoints = vterm_allocator_malloc(state->vt, len * sizeof(uint32_t)); * sequence. */
codepoints = vterm_allocator_malloc(state->vt, (len + 1) * sizeof(uint32_t));
encoding = encoding =
state->gsingle_set ? &state->encoding[state->gsingle_set] : state->gsingle_set ? &state->encoding[state->gsingle_set] :

View File

@@ -771,6 +771,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1467,
/**/ /**/
1466, 1466,
/**/ /**/