]> granicus.if.org Git - vim/commitdiff
patch 7.4.1846 v7.4.1846
authorBram Moolenaar <Bram@vim.org>
Wed, 25 May 2016 20:00:11 +0000 (22:00 +0200)
committerBram Moolenaar <Bram@vim.org>
Wed, 25 May 2016 20:00:11 +0000 (22:00 +0200)
Problem:    Ubsan detects a multiplication overflow.
Solution:   Don't use orig_mouse_time when it's zero. (Dominique Pelle)

src/term.c
src/version.c

index b9af7310102dd2ac8a43143e2ffa4dfe60f3e15e..7ff5af6dc3a4c9a63fea7b39d338d171ad597deb 100644 (file)
@@ -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
index 898ad79ad9f3471f5d23a4a0e4723c1478f5b73e..20267a7f1bdfd0bc1297d63c360ef36f45ef2db3 100644 (file)
@@ -753,6 +753,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1846,
 /**/
     1845,
 /**/