aboutsummaryrefslogtreecommitdiffstats
path: root/src/xterm.c
diff options
context:
space:
mode:
authorDmitry Antipov2014-03-03 12:27:58 +0400
committerDmitry Antipov2014-03-03 12:27:58 +0400
commit19dae293f9fecea07c91440f0a33076c54d39b49 (patch)
treee2ef81c52b8c2dc8ffad510110f3bc71b2b3524f /src/xterm.c
parent8c1c761122b7472617c82fd00c949df52260c903 (diff)
downloademacs-19dae293f9fecea07c91440f0a33076c54d39b49.tar.gz
emacs-19dae293f9fecea07c91440f0a33076c54d39b49.zip
Avoid crashes when X fonts are erroneously freed on reused X
'Display *' connection data (Bug#16069). Note that X font resources still may be leaked, but currently there is no way to completely avoid it. * xterm.h (struct x_display_info): New member x_id. Add comments. * xterm.c (x_display_id): New variable. (x_term_init): Assign identifier to each opened X connection. * xfont.c (struct xfont): New member x_display_id. (xfont_open): Initialize it with frame's display id. (xfont_close): Check whether font's display id matches the one recorded for the given display. Adjust comment. * xftfont.c (struct xftfont_info): (xftfont_open, xftfont_close): Exactly as above with xfont stuff.
Diffstat (limited to 'src/xterm.c')
-rw-r--r--src/xterm.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/xterm.c b/src/xterm.c
index e1873127276..f06225002a7 100644
--- a/src/xterm.c
+++ b/src/xterm.c
@@ -9679,6 +9679,10 @@ my_log_handler (const gchar *log_domain, GLogLevelFlags log_level,
9679} 9679}
9680#endif 9680#endif
9681 9681
9682/* Current X display connection identifier. Incremented for each next
9683 connection established. */
9684static unsigned x_display_id;
9685
9682/* Open a connection to X display DISPLAY_NAME, and return 9686/* Open a connection to X display DISPLAY_NAME, and return
9683 the structure that describes the open display. 9687 the structure that describes the open display.
9684 If we cannot contact the display, return null. */ 9688 If we cannot contact the display, return null. */
@@ -9896,6 +9900,7 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name)
9896 lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@"; 9900 lim = min (PTRDIFF_MAX, SIZE_MAX) - sizeof "@";
9897 if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name)) 9901 if (lim - SBYTES (Vinvocation_name) < SBYTES (Vsystem_name))
9898 memory_full (SIZE_MAX); 9902 memory_full (SIZE_MAX);
9903 dpyinfo->x_id = ++x_display_id;
9899 dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name) 9904 dpyinfo->x_id_name = xmalloc (SBYTES (Vinvocation_name)
9900 + SBYTES (Vsystem_name) + 2); 9905 + SBYTES (Vsystem_name) + 2);
9901 strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"), 9906 strcat (strcat (strcpy (dpyinfo->x_id_name, SSDATA (Vinvocation_name)), "@"),