Mercurial > vim
diff src/libvterm/src/encoding.c @ 13186:dc39ef257b60 v8.0.1467
patch 8.0.1467: libvterm doesn't handle illegal byte sequence correctly
commit https://github.com/vim/vim/commit/fef4ddd5eb8816a6607a624aa401bcfa71a63def
Author: Bram Moolenaar <Bram@vim.org>
Date: Sun Feb 4 14:49:57 2018 +0100
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)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Sun, 04 Feb 2018 15:00:04 +0100 |
parents | 562fa0b252c5 |
children | 2449b6ce1456 |
line wrap: on
line diff
--- a/src/libvterm/src/encoding.c +++ b/src/libvterm/src/encoding.c @@ -46,14 +46,16 @@ static void decode_utf8(VTermEncoding *e return; else if(c >= 0x20 && c < 0x7f) { - if(data->bytes_remaining) + if(data->bytes_remaining) { + data->bytes_remaining = 0; cp[(*cpi)++] = UNICODE_INVALID; - + if (*cpi >= cplen) + break; + } cp[(*cpi)++] = c; #ifdef DEBUG_PRINT_UTF8 printf(" UTF-8 char: U+%04x\n", c); #endif - data->bytes_remaining = 0; } else if(c == 0x7f) /* DEL */