diff options
author | Simon McVittie <smcv@collabora.com> | 2022-07-15 15:08:02 +0100 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2022-07-15 15:59:38 +0100 |
commit | 5cd05bbb5a69a8d96084deafe2810d06a6f81e28 (patch) | |
tree | 1edb99175b867059a4aea4925515e8f52dd56405 /tools | |
parent | 9490157ef960e2d58839afbe7fe0cb8e14b010eb (diff) | |
download | dbus-5cd05bbb5a69a8d96084deafe2810d06a6f81e28.tar.gz |
dbus-launch-x11: Ignore X11 connection when checking for memory leaks
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 these memory leak warnings as uninteresting.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/dbus-launch-x11.c | 21 |
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 |