changeset 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 3b80417c6e2c
children abbd8af60897
files src/term.c src/version.c
diffstat 2 files changed, 21 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/term.c
+++ b/src/term.c
@@ -5031,12 +5031,25 @@ check_termcode(
 		     * Compute the time elapsed since the previous mouse click.
 		     */
 		    gettimeofday(&mouse_time, NULL);
-		    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;
+		    if (orig_mouse_time.tv_sec == 0)
+		    {
+			/*
+			 * Avoid computing the difference between mouse_time
+			 * and orig_mouse_time for the first click, as the
+			 * 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;
 		    if (mouse_code == orig_mouse_code
 			    && timediff < p_mouset
--- a/src/version.c
+++ b/src/version.c
@@ -754,6 +754,8 @@ static char *(features[]) =
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    1846,
+/**/
     1845,
 /**/
     1844,