Mercurial > vim
comparison src/popupwin.c @ 27453:c7f614c9ceb3 v8.2.4255
patch 8.2.4255: theoretical computation overflow
Commit: https://github.com/vim/vim/commit/d5cec1f1f055316c353cfa15ad8d5eb0952d50a0
Author: =?UTF-8?q?Dundar=20G=C3=B6c?= <gocdundar@gmail.com>
Date: Sat Jan 29 15:19:23 2022 +0000
patch 8.2.4255: theoretical computation overflow
Problem: Theoretical computation overflow.
Solution: Perform multiplication in a wider type. (closes https://github.com/vim/vim/issues/9657)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 29 Jan 2022 16:30:03 +0100 |
parents | 79ea140936e9 |
children | d3adf7b141a9 |
comparison
equal
deleted
inserted
replaced
27452:81af1f0ff8ce | 27453:c7f614c9ceb3 |
---|---|
3425 && wp->w_popup_mask_height == height | 3425 && wp->w_popup_mask_height == height |
3426 && wp->w_popup_mask_width == width) | 3426 && wp->w_popup_mask_width == width) |
3427 return; // cache is still valid | 3427 return; // cache is still valid |
3428 | 3428 |
3429 vim_free(wp->w_popup_mask_cells); | 3429 vim_free(wp->w_popup_mask_cells); |
3430 wp->w_popup_mask_cells = alloc_clear(width * height); | 3430 wp->w_popup_mask_cells = alloc_clear((size_t)width * height); |
3431 if (wp->w_popup_mask_cells == NULL) | 3431 if (wp->w_popup_mask_cells == NULL) |
3432 return; | 3432 return; |
3433 cells = wp->w_popup_mask_cells; | 3433 cells = wp->w_popup_mask_cells; |
3434 | 3434 |
3435 FOR_ALL_LIST_ITEMS(wp->w_popup_mask, lio) | 3435 FOR_ALL_LIST_ITEMS(wp->w_popup_mask, lio) |
3637 redrawing_all_win = FALSE; | 3637 redrawing_all_win = FALSE; |
3638 if (redrawing_all_win) | 3638 if (redrawing_all_win) |
3639 mask = popup_mask; | 3639 mask = popup_mask; |
3640 else | 3640 else |
3641 mask = popup_mask_next; | 3641 mask = popup_mask_next; |
3642 vim_memset(mask, 0, screen_Rows * screen_Columns * sizeof(short)); | 3642 vim_memset(mask, 0, (size_t)screen_Rows * screen_Columns * sizeof(short)); |
3643 | 3643 |
3644 // Find the window with the lowest zindex that hasn't been handled yet, | 3644 // Find the window with the lowest zindex that hasn't been handled yet, |
3645 // so that the window with a higher zindex overwrites the value in | 3645 // so that the window with a higher zindex overwrites the value in |
3646 // popup_mask. | 3646 // popup_mask. |
3647 popup_reset_handled(POPUP_HANDLED_4); | 3647 popup_reset_handled(POPUP_HANDLED_4); |
4006 if (wp->w_has_scrollbar) | 4006 if (wp->w_has_scrollbar) |
4007 { | 4007 { |
4008 linenr_T linecount = wp->w_buffer->b_ml.ml_line_count; | 4008 linenr_T linecount = wp->w_buffer->b_ml.ml_line_count; |
4009 int height = wp->w_height; | 4009 int height = wp->w_height; |
4010 | 4010 |
4011 sb_thumb_height = (height * height + linecount / 2) / linecount; | 4011 sb_thumb_height = ((linenr_T)height * height + linecount / 2) |
4012 / linecount; | |
4012 if (wp->w_topline > 1 && sb_thumb_height == height) | 4013 if (wp->w_topline > 1 && sb_thumb_height == height) |
4013 --sb_thumb_height; // scrolled, no full thumb | 4014 --sb_thumb_height; // scrolled, no full thumb |
4014 if (sb_thumb_height == 0) | 4015 if (sb_thumb_height == 0) |
4015 sb_thumb_height = 1; | 4016 sb_thumb_height = 1; |
4016 if (linecount <= wp->w_height) | 4017 if (linecount <= wp->w_height) |