diff --git a/src/email.c b/src/email.c index 2874098b9..8bc4d9ce2 100644 --- a/src/email.c +++ b/src/email.c @@ -243,7 +243,7 @@ handle_compose_email (XdpDbusEmail *object, { g_autofree char *path = NULL; int fd_id; - int fd; + g_autofd int fd = -1; g_variant_get_child (attachment_fds, i, "h", &fd_id); if (fd_id >= g_unix_fd_list_get_length (fd_list)) diff --git a/src/open-uri.c b/src/open-uri.c index c3f6be95b..d07ad81d7 100644 --- a/src/open-uri.c +++ b/src/open-uri.c @@ -610,13 +610,15 @@ handle_open_in_thread_func (GTask *task, g_auto(GVariantBuilder) opts_builder = G_VARIANT_BUILDER_INIT (G_VARIANT_TYPE_VARDICT); gboolean skip_app_chooser = FALSE; - g_auto(XdpFd) fd = -1; + g_autofd int fd = -1; gboolean writable = FALSE; gboolean ask = FALSE; gboolean open_dir = FALSE; gboolean use_default_app = FALSE; const char *reason; + REQUEST_AUTOLOCK (request); + parent_window = (const char *)g_object_get_data (G_OBJECT (request), "parent-window"); uri = g_strdup ((const char *)g_object_get_data (G_OBJECT (request), "uri")); fd = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (request), "fd")); @@ -625,7 +627,7 @@ handle_open_in_thread_func (GTask *task, open_dir = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (request), "open-dir")); activation_token = (const char *)g_object_get_data (G_OBJECT (request), "activation-token"); - REQUEST_AUTOLOCK (request); + g_object_set_data (G_OBJECT (request), "fd", GINT_TO_POINTER (-1)); /* Verify that either uri or fd is set, not both */ if (uri != NULL && fd != -1) @@ -779,9 +781,6 @@ handle_open_in_thread_func (GTask *task, scheme = g_strdup ("file"); uri = g_filename_to_uri (path, NULL, NULL); g_object_set_data_full (G_OBJECT (request), "uri", g_strdup (uri), g_free); - close (fd); - fd = -1; - g_object_set_data (G_OBJECT (request), "fd", GINT_TO_POINTER (-1)); } g_object_set_data_full (G_OBJECT (request), "scheme", g_strdup (scheme), g_free); diff --git a/src/trash.c b/src/trash.c index b35e235dc..29077e4ef 100644 --- a/src/trash.c +++ b/src/trash.c @@ -105,7 +105,8 @@ handle_trash_file (XdpDbusTrash *object, GVariant *arg_fd) { Call *call = call_from_invocation (invocation); - int idx, fd; + int idx; + g_autofd int fd = -1; guint result; g_debug ("Handling TrashFile"); diff --git a/src/wallpaper.c b/src/wallpaper.c index c6e4c42e4..3927d8fe7 100644 --- a/src/wallpaper.c +++ b/src/wallpaper.c @@ -135,7 +135,7 @@ handle_set_wallpaper_in_thread_func (GTask *task, g_autoptr(XdpDbusImplRequest) impl_request = NULL; GVariant *options; gboolean show_preview = FALSE; - int fd; + g_autofd int fd = -1; Permission permission; REQUEST_AUTOLOCK (request); @@ -145,6 +145,8 @@ handle_set_wallpaper_in_thread_func (GTask *task, fd = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (request), "fd")); options = ((GVariant *)g_object_get_data (G_OBJECT (request), "options")); + g_object_set_data (G_OBJECT (request), "fd", GINT_TO_POINTER (-1)); + if (uri != NULL && fd != -1) { g_warning ("Rejecting invalid set-wallpaper request (both URI and fd are set)"); @@ -267,8 +269,6 @@ handle_set_wallpaper_in_thread_func (GTask *task, uri = g_filename_to_uri (path, NULL, NULL); g_object_set_data_full (G_OBJECT (request), "uri", g_strdup (uri), g_free); - close (fd); - g_object_set_data (G_OBJECT (request), "fd", GINT_TO_POINTER (-1)); } impl_request = xdp_dbus_impl_request_proxy_new_sync (g_dbus_proxy_get_connection (G_DBUS_PROXY (impl)),