]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
_dbus_server_new_for_launchd: Don't leak fd on failure
authorSimon McVittie <smcv@collabora.com>
Tue, 21 Nov 2017 14:39:11 +0000 (14:39 +0000)
committerSimon McVittie <smcv@collabora.com>
Fri, 24 Nov 2017 12:17:29 +0000 (12:17 +0000)
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

dbus/dbus-server-launchd.c

index 818ba8cf4ac1963067033b6376ec5510aee317d6..21292973cc825fcf98100885779f30d31b05ac53 100644 (file)
@@ -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;