aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDmitry Antipov2014-12-11 16:26:00 +0300
committerDmitry Antipov2014-12-11 16:26:00 +0300
commit3e92b9882bc5218a5b5962f9e85d0cbca719afc8 (patch)
tree29e4d432a41db080aaa563bf32cfde4b6f92c356 /src
parent9ff164ac6fb3a7a3551679f75e95b306c24fdf33 (diff)
downloademacs-3e92b9882bc5218a5b5962f9e85d0cbca719afc8.tar.gz
emacs-3e92b9882bc5218a5b5962f9e85d0cbca719afc8.zip
Never pass an invalid X connection descriptor to an input reading loop
Fixes: debbugs:19147 * xterm.c (x_delete_terminal): Call emacs_close for X connection descriptor if called from x_connection_closed and always delete this descriptor from keyboard waiting set (Bug#19147).
Diffstat (limited to 'src')
-rw-r--r--src/ChangeLog6
-rw-r--r--src/xterm.c25
2 files changed, 21 insertions, 10 deletions
diff --git a/src/ChangeLog b/src/ChangeLog
index 2a6e2373fcd..27c08580cb8 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,9 @@
12014-12-11 Dmitry Antipov <dmantipov@yandex.ru>
2
3 * xterm.c (x_delete_terminal): Call emacs_close for X connection
4 descriptor if called from x_connection_closed and always delete
5 this descriptor from keyboard waiting set (Bug#19147).
6
12014-12-10 Eli Zaretskii <eliz@gnu.org> 72014-12-10 Eli Zaretskii <eliz@gnu.org>
2 8
3 * bidi.c (BIDI_CACHE_MAX_ELTS_PER_SLOT): New macro. 9 * bidi.c (BIDI_CACHE_MAX_ELTS_PER_SLOT): New macro.
diff --git a/src/xterm.c b/src/xterm.c
index 98f2a27c1ce..1ccc38ca313 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -11318,8 +11318,7 @@ x_delete_terminal (struct terminal *terminal)
11318 xim_close_dpy (dpyinfo); 11318 xim_close_dpy (dpyinfo);
11319#endif 11319#endif
11320 11320
11321 /* If called from x_connection_closed, the display may already be closed 11321 /* Normally, the display is available... */
11322 and dpyinfo->display was set to 0 to indicate that. */
11323 if (dpyinfo->display) 11322 if (dpyinfo->display)
11324 { 11323 {
11325 x_destroy_all_bitmaps (dpyinfo); 11324 x_destroy_all_bitmaps (dpyinfo);
@@ -11360,17 +11359,23 @@ x_delete_terminal (struct terminal *terminal)
11360 XCloseDisplay (dpyinfo->display); 11359 XCloseDisplay (dpyinfo->display);
11361#endif 11360#endif
11362#endif /* ! USE_GTK */ 11361#endif /* ! USE_GTK */
11363 11362 /* Do not close the connection here because it's already closed
11364 /* No more input on this descriptor. Do not close it because 11363 by X(t)CloseDisplay (Bug#18403). */
11365 it's already closed by X(t)CloseDisplay (Bug#18403). */
11366 eassert (0 <= dpyinfo->connection);
11367 delete_keyboard_wait_descriptor (dpyinfo->connection);
11368
11369 /* Mark as dead. */
11370 dpyinfo->display = NULL; 11364 dpyinfo->display = NULL;
11371 dpyinfo->connection = -1;
11372 } 11365 }
11373 11366
11367 /* ...but if called from x_connection_closed, the display may already
11368 be closed and dpyinfo->display was set to 0 to indicate that. Since
11369 X server is most likely gone, explicit close is the only reliable
11370 way to continue and avoid Bug#19147. */
11371 else if (dpyinfo->connection >= 0)
11372 emacs_close (dpyinfo->connection);
11373
11374 /* No more input on this descriptor. */
11375 delete_keyboard_wait_descriptor (dpyinfo->connection);
11376 /* Mark as dead. */
11377 dpyinfo->connection = -1;
11378
11374 x_delete_display (dpyinfo); 11379 x_delete_display (dpyinfo);
11375 unblock_input (); 11380 unblock_input ();
11376} 11381}