diff options
| author | Jan D | 2015-04-04 16:10:06 +0200 |
|---|---|---|
| committer | Jan D | 2015-04-04 16:10:06 +0200 |
| commit | 0115aceb584b007a6faba3de701a972659025fd7 (patch) | |
| tree | 8c43f11438570d0b5ecac2979ecf26baa67542a2 /src | |
| parent | 4fabcbfbcd8447351ae59b01b329a0dabebea872 (diff) | |
| download | emacs-0115aceb584b007a6faba3de701a972659025fd7.tar.gz emacs-0115aceb584b007a6faba3de701a972659025fd7.zip | |
Close a timing hole in selections.
Fixes: debbugs:16737
* src/xselect.c (x_reply_selection_request)
(receive_incremental_selection): Call set_property_change_object
inside block_input.
(wait_for_property_change): Move set property_change_reply(_object)
outside of this function.
(set_property_change_object): New function.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ChangeLog | 9 | ||||
| -rw-r--r-- | src/xselect.c | 28 |
2 files changed, 32 insertions, 5 deletions
diff --git a/src/ChangeLog b/src/ChangeLog index 09225f26dfc..1c3f933d7d8 100644 --- a/src/ChangeLog +++ b/src/ChangeLog | |||
| @@ -1,3 +1,12 @@ | |||
| 1 | 2015-04-04 Jan Djärv <jan.h.d@swipnet.se> | ||
| 2 | |||
| 3 | * xselect.c (x_reply_selection_request) | ||
| 4 | (receive_incremental_selection): Call set_property_change_object | ||
| 5 | inside block_input. | ||
| 6 | (wait_for_property_change): Move set property_change_reply(_object) | ||
| 7 | outside of this function (Bug#16737). | ||
| 8 | (set_property_change_object): New function. | ||
| 9 | |||
| 1 | 2015-04-03 Jan Djärv <jan.h.d@swipnet.se> | 10 | 2015-04-03 Jan Djärv <jan.h.d@swipnet.se> |
| 2 | 11 | ||
| 3 | * xterm.c (handle_one_xevent): Always redraw tool tips on | 12 | * xterm.c (handle_one_xevent): Always redraw tool tips on |
diff --git a/src/xselect.c b/src/xselect.c index 027192dfea2..1570c4fef9c 100644 --- a/src/xselect.c +++ b/src/xselect.c | |||
| @@ -531,6 +531,16 @@ static struct prop_location *property_change_reply_object; | |||
| 531 | 531 | ||
| 532 | static struct prop_location *property_change_wait_list; | 532 | static struct prop_location *property_change_wait_list; |
| 533 | 533 | ||
| 534 | static void | ||
| 535 | set_property_change_object (struct prop_location *location) | ||
| 536 | { | ||
| 537 | /* Input must be blocked so we don't get the event before we set these. */ | ||
| 538 | if (! input_blocked_p ()) | ||
| 539 | emacs_abort (); | ||
| 540 | XSETCAR (property_change_reply, Qnil); | ||
| 541 | property_change_reply_object = location; | ||
| 542 | } | ||
| 543 | |||
| 534 | 544 | ||
| 535 | /* Send the reply to a selection request event EVENT. */ | 545 | /* Send the reply to a selection request event EVENT. */ |
| 536 | 546 | ||
| @@ -633,6 +643,11 @@ x_reply_selection_request (struct input_event *event, | |||
| 633 | { | 643 | { |
| 634 | int format_bytes = cs->format / 8; | 644 | int format_bytes = cs->format / 8; |
| 635 | bool had_errors_p = x_had_errors_p (display); | 645 | bool had_errors_p = x_had_errors_p (display); |
| 646 | |||
| 647 | /* Must set this inside block_input (). unblock_input may read | ||
| 648 | events and setting property_change_reply in | ||
| 649 | wait_for_property_change is then too late. */ | ||
| 650 | set_property_change_object (cs->wait_object); | ||
| 636 | unblock_input (); | 651 | unblock_input (); |
| 637 | 652 | ||
| 638 | bytes_remaining = cs->size; | 653 | bytes_remaining = cs->size; |
| @@ -673,6 +688,8 @@ x_reply_selection_request (struct input_event *event, | |||
| 673 | : format_bytes); | 688 | : format_bytes); |
| 674 | XFlush (display); | 689 | XFlush (display); |
| 675 | had_errors_p = x_had_errors_p (display); | 690 | had_errors_p = x_had_errors_p (display); |
| 691 | // See comment above about property_change_reply. | ||
| 692 | set_property_change_object (cs->wait_object); | ||
| 676 | unblock_input (); | 693 | unblock_input (); |
| 677 | 694 | ||
| 678 | if (had_errors_p) break; | 695 | if (had_errors_p) break; |
| @@ -1059,14 +1076,11 @@ wait_for_property_change (struct prop_location *location) | |||
| 1059 | { | 1076 | { |
| 1060 | ptrdiff_t count = SPECPDL_INDEX (); | 1077 | ptrdiff_t count = SPECPDL_INDEX (); |
| 1061 | 1078 | ||
| 1062 | if (property_change_reply_object) | ||
| 1063 | emacs_abort (); | ||
| 1064 | |||
| 1065 | /* Make sure to do unexpect_property_change if we quit or err. */ | 1079 | /* Make sure to do unexpect_property_change if we quit or err. */ |
| 1066 | record_unwind_protect_ptr (wait_for_property_change_unwind, location); | 1080 | record_unwind_protect_ptr (wait_for_property_change_unwind, location); |
| 1067 | 1081 | ||
| 1068 | XSETCAR (property_change_reply, Qnil); | 1082 | /* See comment in x_reply_selection_request about setting |
| 1069 | property_change_reply_object = location; | 1083 | property_change_reply. Do not do it here. */ |
| 1070 | 1084 | ||
| 1071 | /* If the event we are waiting for arrives beyond here, it will set | 1085 | /* If the event we are waiting for arrives beyond here, it will set |
| 1072 | property_change_reply, because property_change_reply_object says so. */ | 1086 | property_change_reply, because property_change_reply_object says so. */ |
| @@ -1381,6 +1395,8 @@ receive_incremental_selection (struct x_display_info *dpyinfo, | |||
| 1381 | wait_object = expect_property_change (display, window, property, | 1395 | wait_object = expect_property_change (display, window, property, |
| 1382 | PropertyNewValue); | 1396 | PropertyNewValue); |
| 1383 | XFlush (display); | 1397 | XFlush (display); |
| 1398 | // See comment in x_reply_selection_request about property_change_reply. | ||
| 1399 | set_property_change_object (wait_object); | ||
| 1384 | unblock_input (); | 1400 | unblock_input (); |
| 1385 | 1401 | ||
| 1386 | while (true) | 1402 | while (true) |
| @@ -1419,6 +1435,8 @@ receive_incremental_selection (struct x_display_info *dpyinfo, | |||
| 1419 | XDeleteProperty (display, window, property); | 1435 | XDeleteProperty (display, window, property); |
| 1420 | wait_object = expect_property_change (display, window, property, | 1436 | wait_object = expect_property_change (display, window, property, |
| 1421 | PropertyNewValue); | 1437 | PropertyNewValue); |
| 1438 | // See comment in x_reply_selection_request about property_change_reply. | ||
| 1439 | set_property_change_object (wait_object); | ||
| 1422 | XFlush (display); | 1440 | XFlush (display); |
| 1423 | unblock_input (); | 1441 | unblock_input (); |
| 1424 | 1442 | ||