comparison 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
comparison
equal deleted inserted replaced
13185:13fed273cfd6 13186:dc39ef257b60
246 VTermEncodingInstance *encoding; 246 VTermEncodingInstance *encoding;
247 int i = 0; 247 int i = 0;
248 248
249 VTermPos oldpos = state->pos; 249 VTermPos oldpos = state->pos;
250 250
251 /* We'll have at most len codepoints */ 251 /* We'll have at most len codepoints, plus one from a previous incomplete
252 codepoints = vterm_allocator_malloc(state->vt, len * sizeof(uint32_t)); 252 * sequence. */
253 codepoints = vterm_allocator_malloc(state->vt, (len + 1) * sizeof(uint32_t));
253 254
254 encoding = 255 encoding =
255 state->gsingle_set ? &state->encoding[state->gsingle_set] : 256 state->gsingle_set ? &state->encoding[state->gsingle_set] :
256 !(bytes[eaten] & 0x80) ? &state->encoding[state->gl_set] : 257 !(bytes[eaten] & 0x80) ? &state->encoding[state->gl_set] :
257 state->vt->mode.utf8 ? &state->encoding_utf8 : 258 state->vt->mode.utf8 ? &state->encoding_utf8 :