aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKen Raeburn2015-11-24 01:16:10 -0500
committerKen Raeburn2015-11-24 03:51:13 -0500
commitcb1bd3496594d5e4060d990b4c6bac748fb974c9 (patch)
tree96dc17b8a41b4207c33a45fee7eaf839dc54d0c9 /src
parentb8bf03161123de6de5570fd3f4d1cf3ed94084e1 (diff)
downloademacs-cb1bd3496594d5e4060d990b4c6bac748fb974c9.tar.gz
emacs-cb1bd3496594d5e4060d990b4c6bac748fb974c9.zip
Fix kbd_buffer iteration loop in readable_events
* src/keyboard.c (readable_events): Wrap the event pointer back to the start of the kbd_buffer array inside the top of the loop instead of right before checking the loop condition, since kbd_fetch_ptr and kbd_store_ptr point past the end of the array to mean that element 0 is next. (bug#21935)
Diffstat (limited to 'src')
-rw-r--r--src/keyboard.c10
1 files changed, 3 insertions, 7 deletions
diff --git a/src/keyboard.c b/src/keyboard.c
index 849066c3c26..c9e58e7a086 100644
--- a/src/keyboard.c
+++ b/src/keyboard.c
@@ -3313,14 +3313,12 @@ readable_events (int flags)
3313#endif 3313#endif
3314 )) 3314 ))
3315 { 3315 {
3316 union buffered_input_event *event; 3316 union buffered_input_event *event = kbd_fetch_ptr;
3317
3318 event = ((kbd_fetch_ptr < kbd_buffer + KBD_BUFFER_SIZE)
3319 ? kbd_fetch_ptr
3320 : kbd_buffer);
3321 3317
3322 do 3318 do
3323 { 3319 {
3320 if (event == kbd_buffer + KBD_BUFFER_SIZE)
3321 event = kbd_buffer;
3324 if (!( 3322 if (!(
3325#ifdef USE_TOOLKIT_SCROLL_BARS 3323#ifdef USE_TOOLKIT_SCROLL_BARS
3326 (flags & READABLE_EVENTS_FILTER_EVENTS) && 3324 (flags & READABLE_EVENTS_FILTER_EVENTS) &&
@@ -3337,8 +3335,6 @@ readable_events (int flags)
3337 && event->kind == BUFFER_SWITCH_EVENT)) 3335 && event->kind == BUFFER_SWITCH_EVENT))
3338 return 1; 3336 return 1;
3339 event++; 3337 event++;
3340 if (event == kbd_buffer + KBD_BUFFER_SIZE)
3341 event = kbd_buffer;
3342 } 3338 }
3343 while (event != kbd_store_ptr); 3339 while (event != kbd_store_ptr);
3344 } 3340 }