0
0
mirror of https://github.com/vim/vim.git synced 2025-09-26 04:04:07 -04:00

patch 7.4.1846

Problem:    Ubsan detects a multiplication overflow.
Solution:   Don't use orig_mouse_time when it's zero. (Dominique Pelle)
This commit is contained in:
Bram Moolenaar
2016-05-25 22:00:11 +02:00
parent f8df45d84f
commit 54c10ccf92
2 changed files with 21 additions and 6 deletions

View File

@@ -5031,12 +5031,25 @@ check_termcode(
* Compute the time elapsed since the previous mouse click. * Compute the time elapsed since the previous mouse click.
*/ */
gettimeofday(&mouse_time, NULL); gettimeofday(&mouse_time, NULL);
timediff = (mouse_time.tv_usec if (orig_mouse_time.tv_sec == 0)
- orig_mouse_time.tv_usec) / 1000; {
if (timediff < 0) /*
--orig_mouse_time.tv_sec; * Avoid computing the difference between mouse_time
timediff += (mouse_time.tv_sec * and orig_mouse_time for the first click, as the
- orig_mouse_time.tv_sec) * 1000; * difference would be huge and would cause multiplication
* overflow.
*/
timediff = p_mouset;
}
else
{
timediff = (mouse_time.tv_usec
- orig_mouse_time.tv_usec) / 1000;
if (timediff < 0)
--orig_mouse_time.tv_sec;
timediff += (mouse_time.tv_sec
- orig_mouse_time.tv_sec) * 1000;
}
orig_mouse_time = mouse_time; orig_mouse_time = mouse_time;
if (mouse_code == orig_mouse_code if (mouse_code == orig_mouse_code
&& timediff < p_mouset && timediff < p_mouset

View File

@@ -753,6 +753,8 @@ static char *(features[]) =
static int included_patches[] = static int included_patches[] =
{ /* Add new patch number below this line */ { /* Add new patch number below this line */
/**/
1846,
/**/ /**/
1845, 1845,
/**/ /**/