Mercurial > vim
diff src/libvterm/src/state.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 | db99bd23c87f |
children | 5e47c4bdf3a6 |
line wrap: on
line diff
--- a/src/libvterm/src/state.c +++ b/src/libvterm/src/state.c @@ -248,8 +248,9 @@ static int on_text(const char bytes[], s VTermPos oldpos = state->pos; - /* We'll have at most len codepoints */ - codepoints = vterm_allocator_malloc(state->vt, len * sizeof(uint32_t)); + /* We'll have at most len codepoints, plus one from a previous incomplete + * sequence. */ + codepoints = vterm_allocator_malloc(state->vt, (len + 1) * sizeof(uint32_t)); encoding = state->gsingle_set ? &state->encoding[state->gsingle_set] :