comparison src/libvterm/src/screen.c @ 20957:2f2bc98a8dfb v8.2.1030

patch 8.2.1030: reducing size of a terminal window may cause a crash Commit: https://github.com/vim/vim/commit/da58134eedf43ae4b9013c93ecbdf55e4da4b8a3 Author: Bram Moolenaar <Bram@vim.org> Date: Sun Jun 21 17:57:32 2020 +0200 patch 8.2.1030: reducing size of a terminal window may cause a crash Problem: Reducing size of a terminal window may cause a crash. Solution: Make sure the row and column don't become negative. (closes https://github.com/vim/vim/issues/6273)
author Bram Moolenaar <Bram@vim.org>
date Sun, 21 Jun 2020 18:00:04 +0200
parents 88cec48503b8
children 66618893eb2a
comparison
equal deleted inserted replaced
20956:be36cdf5d8a0 20957:2f2bc98a8dfb
644 644
645 if(newinfo->doublewidth != oldinfo->doublewidth || 645 if(newinfo->doublewidth != oldinfo->doublewidth ||
646 newinfo->doubleheight != oldinfo->doubleheight) { 646 newinfo->doubleheight != oldinfo->doubleheight) {
647 for(col = 0; col < screen->cols; col++) { 647 for(col = 0; col < screen->cols; col++) {
648 ScreenCell *cell = getcell(screen, row, col); 648 ScreenCell *cell = getcell(screen, row, col);
649 if (cell == NULL)
650 {
651 DEBUG_LOG2("libvterm: setlineinfo() position invalid: %d / %d",
652 row, col);
653 return 1;
654 }
649 cell->pen.dwl = newinfo->doublewidth; 655 cell->pen.dwl = newinfo->doublewidth;
650 cell->pen.dhl = newinfo->doubleheight; 656 cell->pen.dhl = newinfo->doubleheight;
651 } 657 }
652 658
653 rect.start_row = row; 659 rect.start_row = row;
771 for(row = rect.start_row; row < rect.end_row; row++) { 777 for(row = rect.start_row; row < rect.end_row; row++) {
772 for(col = rect.start_col; col < rect.end_col; col++) { 778 for(col = rect.start_col; col < rect.end_col; col++) {
773 ScreenCell *cell = getcell(screen, row, col); 779 ScreenCell *cell = getcell(screen, row, col);
774 int i; 780 int i;
775 781
782 if (cell == NULL)
783 {
784 DEBUG_LOG2("libvterm: _get_chars() position invalid: %d / %d",
785 row, col);
786 return 1;
787 }
776 if(cell->chars[0] == 0) 788 if(cell->chars[0] == 0)
777 // Erased cell, might need a space 789 // Erased cell, might need a space
778 padding++; 790 padding++;
779 else if(cell->chars[0] == (uint32_t)-1) 791 else if(cell->chars[0] == (uint32_t)-1)
780 // Gap behind a double-width char, do nothing 792 // Gap behind a double-width char, do nothing