Mercurial > vim
comparison src/popupwin.c @ 17274:6a7ba68d448e v8.1.1636
patch 8.1.1636: crash when popup has fitting scrollbar
commit https://github.com/vim/vim/commit/437a746b4c1bd65cecc2e9095e911b58b13fce77
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Jul 5 20:17:22 2019 +0200
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 https://github.com/vim/vim/issues/4615)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 05 Jul 2019 20:30:07 +0200 |
parents | 13a2d3364b3f |
children | 8a095d343c59 |
comparison
equal
deleted
inserted
replaced
17273:25b99b296474 | 17274:6a7ba68d448e |
---|---|
2461 | 2461 |
2462 sb_thumb_height = (wp->w_height * wp->w_height + linecount / 2) | 2462 sb_thumb_height = (wp->w_height * wp->w_height + linecount / 2) |
2463 / linecount; | 2463 / linecount; |
2464 if (sb_thumb_height == 0) | 2464 if (sb_thumb_height == 0) |
2465 sb_thumb_height = 1; | 2465 sb_thumb_height = 1; |
2466 sb_thumb_top = (wp->w_topline - 1 + (linecount / wp->w_height) / 2) | 2466 if (linecount <= wp->w_height) |
2467 // it just fits, avoid divide by zero | |
2468 sb_thumb_top = 0; | |
2469 else | |
2470 sb_thumb_top = (wp->w_topline - 1 | |
2471 + (linecount / wp->w_height) / 2) | |
2467 * (wp->w_height - sb_thumb_height) | 2472 * (wp->w_height - sb_thumb_height) |
2468 / (linecount - wp->w_height); | 2473 / (linecount - wp->w_height); |
2469 if (wp->w_scrollbar_highlight != NULL) | 2474 if (wp->w_scrollbar_highlight != NULL) |
2470 attr_scroll = syn_name2attr(wp->w_scrollbar_highlight); | 2475 attr_scroll = syn_name2attr(wp->w_scrollbar_highlight); |
2471 else | 2476 else |