0
0
mirror of https://github.com/vim/vim.git synced 2025-09-23 03:43:49 -04:00

patch 8.1.1636: crash when popup has fitting scrollbar

Problem:    Crash when popup has fitting scrollbar. (Trygve Aaberge)
Solution:   Don't divide by zero if the scrollbar just fits. (closes #4615)
This commit is contained in:
Bram Moolenaar
2019-07-05 20:17:22 +02:00
parent b4d9b893d3
commit 437a746b4c
3 changed files with 20 additions and 1 deletions

View File

@@ -2463,7 +2463,12 @@ update_popups(void (*win_update)(win_T *wp))
/ linecount;
if (sb_thumb_height == 0)
sb_thumb_height = 1;
sb_thumb_top = (wp->w_topline - 1 + (linecount / wp->w_height) / 2)
if (linecount <= wp->w_height)
// it just fits, avoid divide by zero
sb_thumb_top = 0;
else
sb_thumb_top = (wp->w_topline - 1
+ (linecount / wp->w_height) / 2)
* (wp->w_height - sb_thumb_height)
/ (linecount - wp->w_height);
if (wp->w_scrollbar_highlight != NULL)