summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon McVittie <smcv@collabora.com>2017-11-21 14:39:11 +0000
committerSimon McVittie <smcv@collabora.com>2017-11-24 12:17:29 +0000
commit1ecaff10dab4bd9b57b466aff18a650b6a8c3c06 (patch)
treea675f6cb611fe713591c9f1d38afd7045a8c631d
parent0c03b505a9718c6d497caffb7d6083371679a852 (diff)
_dbus_server_new_for_launchd: Don't leak fd on failure
If _dbus_server_new_for_socket() fails, it is the caller's responsibility to close the fds. All other callers did this. Signed-off-by: Simon McVittie <smcv@collabora.com> Reviewed-by: Philip Withnall <withnall@endlessm.com> Bug: https://bugs.freedesktop.org/show_bug.cgi?id=89104
-rw-r--r--dbus/dbus-server-launchd.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/dbus/dbus-server-launchd.c b/dbus/dbus-server-launchd.c
index 818ba8cf4..21292973c 100644
--- a/dbus/dbus-server-launchd.c
+++ b/dbus/dbus-server-launchd.c
@@ -68,7 +68,7 @@ _dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error)
#ifdef DBUS_ENABLE_LAUNCHD
DBusServer *server;
DBusString address;
- int launchd_fd;
+ int launchd_fd = -1;
launch_data_t sockets_dict, checkin_response;
launch_data_t checkin_request;
launch_data_t listening_fd_array, listening_fd;
@@ -196,6 +196,9 @@ _dbus_server_new_for_launchd (const char *launchd_env_var, DBusError * error)
return server;
l_failed_0:
+ if (launchd_fd >= 0)
+ close (launchd_fd);
+
_dbus_string_free (&address);
return NULL;