From 1342d99efc6342fcc54c64cf9fa01437566a60c3 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 21 Nov 2017 14:39:11 +0000 Subject: [PATCH 06/12] [UNTESTED] _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 --- dbus/dbus-server-launchd.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dbus/dbus-server-launchd.c b/dbus/dbus-server-launchd.c index 818ba8cf..21292973 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; -- 2.15.0