]> git.eshelyaron.com Git - emacs.git/commitdiff
* keyboard.c (make_lispy_event): Fix problem in integer overflow.
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 12 May 2011 19:37:40 +0000 (12:37 -0700)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 12 May 2011 19:37:40 +0000 (12:37 -0700)
Don't assume that the difference between two unsigned long values
can fit into an integer.  At this point, we know button_down_time
<= event->timestamp, so the difference must be nonnegative, so
there's no need to cast the result if double-click-time is
nonnegative, as it should be; check that it's nonnegative, just in
case.  This bug is triggered when events are more than 2**31 ms
apart (about 25 days).

src/ChangeLog
src/keyboard.c

index 4d6251f6bded67c3e3ece743e4e68f883f8904de..5760bfc2a1c38572330a25c7fc5690f59ff4f61c 100644 (file)
@@ -1,5 +1,14 @@
 2011-05-12  Paul Eggert  <eggert@cs.ucla.edu>
 
+       * keyboard.c (make_lispy_event): Fix problem in integer overflow.
+       Don't assume that the difference between two unsigned long values
+       can fit into an integer.  At this point, we know button_down_time
+       <= event->timestamp, so the difference must be nonnegative, so
+       there's no need to cast the result if double-click-time is
+       nonnegative, as it should be; check that it's nonnegative, just in
+       case.  This bug is triggered when events are more than 2**31 ms
+       apart (about 25 days).
+
        * xselect.c (last_event_timestamp): Remove duplicate decl.
        (x_own_selection): Remove needless cast to unsigned long.
 
index a94456fce2eedd50d6528519196d4cdc7ce87618..287996ffba93d4eddcc0fa57b79c3f954688ec8f 100644 (file)
@@ -5556,9 +5556,9 @@ make_lispy_event (struct input_event *event)
                       && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
                       && button_down_time != 0
                       && (EQ (Vdouble_click_time, Qt)
-                          || (INTEGERP (Vdouble_click_time)
-                              && ((int)(event->timestamp - button_down_time)
-                                  < XINT (Vdouble_click_time)))));
+                          || (NATNUMP (Vdouble_click_time)
+                              && (event->timestamp - button_down_time
+                                  < XFASTINT (Vdouble_click_time)))));
        }
 
        last_mouse_button = button;
@@ -5742,9 +5742,9 @@ make_lispy_event (struct input_event *event)
                       && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
                       && button_down_time != 0
                       && (EQ (Vdouble_click_time, Qt)
-                          || (INTEGERP (Vdouble_click_time)
-                              && ((int)(event->timestamp - button_down_time)
-                                  < XINT (Vdouble_click_time)))));
+                          || (NATNUMP (Vdouble_click_time)
+                              && (event->timestamp - button_down_time
+                                  < XFASTINT (Vdouble_click_time)))));
          if (is_double)
            {
              double_click_count++;