comparison src/libvterm/src/state.c @ 20875:88cec48503b8 v8.2.0989

patch 8.2.0989: crash after resizing a terminal window Commit: https://github.com/vim/vim/commit/a6e8bf2d8929ef52eeda495e0e0c3d2bff8f5830 Author: Bram Moolenaar <Bram@vim.org> Date: Tue Jun 16 20:58:07 2020 +0200 patch 8.2.0989: crash after resizing a terminal window Problem: Crash after resizing a terminal window. (August Masquelier) Solution: Add check for valid row in libvterm. (closes https://github.com/vim/vim/issues/6273)
author Bram Moolenaar <Bram@vim.org>
date Tue, 16 Jun 2020 21:00:05 +0200
parents a4652d7ec99f
children 5c6a6b5a3330
comparison
equal deleted inserted replaced
20874:cc48460d0b8f 20875:88cec48503b8
14 /* Some convenient wrappers to make callback functions easier */ 14 /* Some convenient wrappers to make callback functions easier */
15 15
16 static void putglyph(VTermState *state, const uint32_t chars[], int width, VTermPos pos) 16 static void putglyph(VTermState *state, const uint32_t chars[], int width, VTermPos pos)
17 { 17 {
18 VTermGlyphInfo info; 18 VTermGlyphInfo info;
19
20 if (pos.row >= state->rows)
21 {
22 DEBUG_LOG2("libvterm: putglyph() pos.row %d out of range (rows = %d)\n", pos.row, state.rows);
23 return;
24 }
19 info.chars = chars; 25 info.chars = chars;
20 info.width = width; 26 info.width = width;
21 info.protected_cell = state->protected_cell; 27 info.protected_cell = state->protected_cell;
22 info.dwl = state->lineinfo[pos.row].doublewidth; 28 info.dwl = state->lineinfo[pos.row].doublewidth;
23 info.dhl = state->lineinfo[pos.row].doubleheight; 29 info.dhl = state->lineinfo[pos.row].doubleheight;
281 VTermEncodingInstance *encoding; 287 VTermEncodingInstance *encoding;
282 int i = 0; 288 int i = 0;
283 289
284 VTermPos oldpos = state->pos; 290 VTermPos oldpos = state->pos;
285 291
292 if (state->pos.row >= state->rows)
293 {
294 DEBUG_LOG2("libvterm: on_text() pos.row %d out of range (rows = %d)\n", state->pos.row, state.rows);
295 return 0;
296 }
286 // We'll have at most len codepoints, plus one from a previous incomplete 297 // We'll have at most len codepoints, plus one from a previous incomplete
287 // sequence. 298 // sequence.
288 codepoints = vterm_allocator_malloc(state->vt, (len + 1) * sizeof(uint32_t)); 299 codepoints = vterm_allocator_malloc(state->vt, (len + 1) * sizeof(uint32_t));
289 if (codepoints == NULL) 300 if (codepoints == NULL)
290 return 0; 301 return 0;