[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ae0ec1eede: Plug big leaks upon display IO error
From: |
Po Lu |
Subject: |
master ae0ec1eede: Plug big leaks upon display IO error |
Date: |
Sun, 30 Oct 2022 01:14:00 -0400 (EDT) |
branch: master
commit ae0ec1eede3dac8ae82c3a82d7d7f6b956d8db24
Author: Po Lu <luangruo@yahoo.com>
Commit: Po Lu <luangruo@yahoo.com>
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.
---
src/xterm.c | 20 ++++++++++++--------
1 file changed, 12 insertions(+), 8 deletions(-)
diff --git a/src/xterm.c b/src/xterm.c
index f1bccddb6c..7dd969b821 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. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master ae0ec1eede: Plug big leaks upon display IO error,
Po Lu <=