aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPaul Eggert2011-05-12 12:37:40 -0700
committerPaul Eggert2011-05-12 12:37:40 -0700
commit8e55734abd164a7b170380ce0413d1d792429ce8 (patch)
tree6a9177c5130c419c089ee64d06b231aefed44afa /src
parent6434756cc552458f871b66dbd28692c8de69633c (diff)
downloademacs-8e55734abd164a7b170380ce0413d1d792429ce8.tar.gz
emacs-8e55734abd164a7b170380ce0413d1d792429ce8.zip
* 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).
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog9
-rw-r--r--src/keyboard.c12
2 files changed, 15 insertions, 6 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 4d6251f6bde..5760bfc2a1c 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,5 +1,14 @@
12011-05-12 Paul Eggert <eggert@cs.ucla.edu> 12011-05-12 Paul Eggert <eggert@cs.ucla.edu>
2 2
3 * keyboard.c (make_lispy_event): Fix problem in integer overflow.
4 Don't assume that the difference between two unsigned long values
5 can fit into an integer. At this point, we know button_down_time
6 <= event->timestamp, so the difference must be nonnegative, so
7 there's no need to cast the result if double-click-time is
8 nonnegative, as it should be; check that it's nonnegative, just in
9 case. This bug is triggered when events are more than 2**31 ms
10 apart (about 25 days).
11
3 * xselect.c (last_event_timestamp): Remove duplicate decl. 12 * xselect.c (last_event_timestamp): Remove duplicate decl.
4 (x_own_selection): Remove needless cast to unsigned long. 13 (x_own_selection): Remove needless cast to unsigned long.
5 14
diff --git a/src/keyboard.c b/src/keyboard.c
index a94456fce2e..287996ffba9 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -5556,9 +5556,9 @@ make_lispy_event (struct input_event *event)
5556 && (eabs (XINT (event->y) - last_mouse_y) <= fuzz) 5556 && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
5557 && button_down_time != 0 5557 && button_down_time != 0
5558 && (EQ (Vdouble_click_time, Qt) 5558 && (EQ (Vdouble_click_time, Qt)
5559 || (INTEGERP (Vdouble_click_time) 5559 || (NATNUMP (Vdouble_click_time)
5560 && ((int)(event->timestamp - button_down_time) 5560 && (event->timestamp - button_down_time
5561 < XINT (Vdouble_click_time))))); 5561 < XFASTINT (Vdouble_click_time)))));
5562 } 5562 }
5563 5563
5564 last_mouse_button = button; 5564 last_mouse_button = button;
@@ -5742,9 +5742,9 @@ make_lispy_event (struct input_event *event)
5742 && (eabs (XINT (event->y) - last_mouse_y) <= fuzz) 5742 && (eabs (XINT (event->y) - last_mouse_y) <= fuzz)
5743 && button_down_time != 0 5743 && button_down_time != 0
5744 && (EQ (Vdouble_click_time, Qt) 5744 && (EQ (Vdouble_click_time, Qt)
5745 || (INTEGERP (Vdouble_click_time) 5745 || (NATNUMP (Vdouble_click_time)
5746 && ((int)(event->timestamp - button_down_time) 5746 && (event->timestamp - button_down_time
5747 < XINT (Vdouble_click_time))))); 5747 < XFASTINT (Vdouble_click_time)))));
5748 if (is_double) 5748 if (is_double)
5749 { 5749 {
5750 double_click_count++; 5750 double_click_count++;