summaryrefslogtreecommitdiff
path: root/tools/dbus-launch-x11.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/dbus-launch-x11.c')
-rw-r--r--tools/dbus-launch-x11.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/tools/dbus-launch-x11.c b/tools/dbus-launch-x11.c
index 0b5d2928..48ab51d8 100644
--- a/tools/dbus-launch-x11.c
+++ b/tools/dbus-launch-x11.c
@@ -37,6 +37,8 @@
#include <X11/Xlib.h>
#include <X11/Xatom.h>
+#include "dbus/dbus-internals.h"
+
Display *xdisplay = NULL;
static Atom selection_atom;
static Atom address_atom;
@@ -451,7 +453,24 @@ x11_save_address (char *address, pid_t pid, long *wid)
int
x11_init (void)
{
- return open_x11 () != NULL && init_x_atoms (xdisplay);
+ int ok;
+
+ /*
+ * The X11 connection is opened and never closed. Because dbus-launch
+ * forks and continues to run non-trivial code in a forked child, it is
+ * not clear whether (or where) it would be safe to close it; instead, we
+ * leave it open until process exit, at which point the socket is cleaned
+ * up by the kernel.
+ *
+ * Any memory allocated for the X11 connection is only allocated once per
+ * run of dbus-launch, so there's no need to keep track of it, and we can
+ * silence memory leak warnings from AddressSanitizer as uninteresting.
+ */
+ _DBUS_BEGIN_IGNORE_LEAKS;
+ ok = open_x11 () != NULL && init_x_atoms (xdisplay);
+ _DBUS_END_IGNORE_LEAKS;
+
+ return ok;
}
void