diff options
author | Po Lu <luangruo@yahoo.com> | 2022-10-30 13:13:28 +0800 |
---|---|---|
committer | Po Lu <luangruo@yahoo.com> | 2022-10-30 13:13:28 +0800 |
commit | ae0ec1eede3dac8ae82c3a82d7d7f6b956d8db24 (patch) | |
tree | d61891fb1d50fc54f079beb6f0c91d0b5b12353e | |
parent | 1d62c964238a82ccfcbd07a554abe8e6c096fcd5 (diff) | |
download | emacs-ae0ec1eede3dac8ae82c3a82d7d7f6b956d8db24.tar.gz |
Plug big leaks upon display IO error
Frame GCs are still leaked, but there is nothing that can be
done in that case because the display connection is dead.
* src/xterm.c (x_delete_terminal): Always free xkb desc and
modmap.
-rw-r--r-- | src/xterm.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/xterm.c b/src/xterm.c index f1bccddb6c3..7dd969b821f 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -30277,11 +30277,6 @@ x_delete_terminal (struct terminal *terminal) closing all the displays. */ XrmDestroyDatabase (dpyinfo->rdb); #endif - -#ifdef HAVE_XKB - if (dpyinfo->xkb_desc) - XkbFreeKeyboard (dpyinfo->xkb_desc, XkbAllComponentsMask, True); -#endif #ifdef USE_GTK xg_display_close (dpyinfo->display); #else @@ -30291,9 +30286,6 @@ x_delete_terminal (struct terminal *terminal) XCloseDisplay (dpyinfo->display); #endif #endif /* ! USE_GTK */ - - if (dpyinfo->modmap) - XFreeModifiermap (dpyinfo->modmap); /* Do not close the connection here because it's already closed by X(t)CloseDisplay (Bug#18403). */ dpyinfo->display = NULL; @@ -30306,6 +30298,18 @@ x_delete_terminal (struct terminal *terminal) else if (dpyinfo->connection >= 0) emacs_close (dpyinfo->connection); + /* Free the keyboard and modifier maps here; that is safe to do + without a display, and not doing so leads to a lot of data being + leaked upon IO error. */ + +#ifdef HAVE_XKB + if (dpyinfo->xkb_desc) + XkbFreeKeyboard (dpyinfo->xkb_desc, XkbAllComponentsMask, True); +#endif + + if (dpyinfo->modmap) + XFreeModifiermap (dpyinfo->modmap); + /* No more input on this descriptor. */ delete_keyboard_wait_descriptor (dpyinfo->connection); /* Mark as dead. */ |