diff options
author | =?UTF-8?q?Dundar=20G=C3=B6c?= <gocdundar@gmail.com> | 2022-01-29 15:19:23 +0000 |
---|---|---|
committer | Bram Moolenaar <Bram@vim.org> | 2022-01-29 15:19:23 +0000 |
commit | d5cec1f1f055316c353cfa15ad8d5eb0952d50a0 (patch) | |
tree | 94d3ad44783e3442be7293edb3d5890ac08f0377 /src/popupwin.c | |
parent | f12b7815f6b55c3e2f37366aa45e723b1fcb2e9a (diff) |
patch 8.2.4255: theoretical computation overflowv8.2.4255
Problem: Theoretical computation overflow.
Solution: Perform multiplication in a wider type. (closes #9657)
Diffstat (limited to 'src/popupwin.c')
-rw-r--r-- | src/popupwin.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/popupwin.c b/src/popupwin.c index ec7623d0f7..9dee7579e5 100644 --- a/src/popupwin.c +++ b/src/popupwin.c @@ -3427,7 +3427,7 @@ popup_update_mask(win_T *wp, int width, int height) return; // cache is still valid vim_free(wp->w_popup_mask_cells); - wp->w_popup_mask_cells = alloc_clear(width * height); + wp->w_popup_mask_cells = alloc_clear((size_t)width * height); if (wp->w_popup_mask_cells == NULL) return; cells = wp->w_popup_mask_cells; @@ -3639,7 +3639,7 @@ may_update_popup_mask(int type) mask = popup_mask; else mask = popup_mask_next; - vim_memset(mask, 0, screen_Rows * screen_Columns * sizeof(short)); + vim_memset(mask, 0, (size_t)screen_Rows * screen_Columns * sizeof(short)); // Find the window with the lowest zindex that hasn't been handled yet, // so that the window with a higher zindex overwrites the value in @@ -4008,7 +4008,8 @@ update_popups(void (*win_update)(win_T *wp)) linenr_T linecount = wp->w_buffer->b_ml.ml_line_count; int height = wp->w_height; - sb_thumb_height = (height * height + linecount / 2) / linecount; + sb_thumb_height = ((linenr_T)height * height + linecount / 2) + / linecount; if (wp->w_topline > 1 && sb_thumb_height == height) --sb_thumb_height; // scrolled, no full thumb if (sb_thumb_height == 0) |