Mercurial > vim
comparison src/term.c @ 9125:bcc132f80109 v7.4.1846
commit https://github.com/vim/vim/commit/54c10ccf9274880e83093a99690e7bfa9a2d2fa8
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed May 25 22:00:11 2016 +0200
patch 7.4.1846
Problem: Ubsan detects a multiplication overflow.
Solution: Don't use orig_mouse_time when it's zero. (Dominique Pelle)
author | Christian Brabandt <cb@256bit.org> |
---|---|
date | Wed, 25 May 2016 22:15:04 +0200 |
parents | 0a3bc9fdea20 |
children | 69ed2c9d34a6 |
comparison
equal
deleted
inserted
replaced
9124:3b80417c6e2c | 9125:bcc132f80109 |
---|---|
5029 { | 5029 { |
5030 /* | 5030 /* |
5031 * Compute the time elapsed since the previous mouse click. | 5031 * Compute the time elapsed since the previous mouse click. |
5032 */ | 5032 */ |
5033 gettimeofday(&mouse_time, NULL); | 5033 gettimeofday(&mouse_time, NULL); |
5034 timediff = (mouse_time.tv_usec | 5034 if (orig_mouse_time.tv_sec == 0) |
5035 - orig_mouse_time.tv_usec) / 1000; | 5035 { |
5036 if (timediff < 0) | 5036 /* |
5037 --orig_mouse_time.tv_sec; | 5037 * Avoid computing the difference between mouse_time |
5038 timediff += (mouse_time.tv_sec | 5038 * and orig_mouse_time for the first click, as the |
5039 - orig_mouse_time.tv_sec) * 1000; | 5039 * difference would be huge and would cause multiplication |
5040 * overflow. | |
5041 */ | |
5042 timediff = p_mouset; | |
5043 } | |
5044 else | |
5045 { | |
5046 timediff = (mouse_time.tv_usec | |
5047 - orig_mouse_time.tv_usec) / 1000; | |
5048 if (timediff < 0) | |
5049 --orig_mouse_time.tv_sec; | |
5050 timediff += (mouse_time.tv_sec | |
5051 - orig_mouse_time.tv_sec) * 1000; | |
5052 } | |
5040 orig_mouse_time = mouse_time; | 5053 orig_mouse_time = mouse_time; |
5041 if (mouse_code == orig_mouse_code | 5054 if (mouse_code == orig_mouse_code |
5042 && timediff < p_mouset | 5055 && timediff < p_mouset |
5043 && orig_num_clicks != 4 | 5056 && orig_num_clicks != 4 |
5044 && orig_mouse_col == mouse_col | 5057 && orig_mouse_col == mouse_col |