summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2017-05-31 12:10:25 -0400
committerMatthias Clasen <mclasen@redhat.com>2017-06-22 08:55:34 -0400
commit098f9c6088ff7d9aad5199294f0b2fc70604eec0 (patch)
tree9954989a335c99dbebd969d2c846851ca3cc3390
parent7cb7967cf563a57e7d2012088403ac29fad436eb (diff)
downloadglib-098f9c6088ff7d9aad5199294f0b2fc70604eec0.tar.gz
OpenFile support: Handle open failing
This can happen, report it as an error when it does.
-rw-r--r--gio/gopenuriportal.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/gio/gopenuriportal.c b/gio/gopenuriportal.c
index 973190b70..fb8289b3a 100644
--- a/gio/gopenuriportal.c
+++ b/gio/gopenuriportal.c
@@ -107,6 +107,13 @@ g_openuri_portal_open_uri (const char *uri,
path = g_file_get_path (file);
fd = g_open (path, O_PATH | O_CLOEXEC);
+ if (fd == -1)
+ {
+ g_set_error (error, G_IO_ERROR, g_io_error_from_errno (errno),
+ "Failed to open '%s'", path);
+ return FALSE;
+ }
+
#ifndef HAVE_O_CLOEXEC
fcntl (fd, F_SETFD, FD_CLOEXEC);
#endif
@@ -262,6 +269,14 @@ g_openuri_portal_open_uri_async (const char *uri,
path = g_file_get_path (file);
fd = g_open (path, O_PATH | O_CLOEXEC);
+ if (fd == -1)
+ {
+ g_task_report_new_error (NULL, callback, user_data, NULL,
+ G_IO_ERROR, g_io_error_from_errno (errno),
+ "OpenURI portal is not available");
+ return;
+ }
+
#ifndef HAVE_O_CLOEXEC
fcntl (fd, F_SETFD, FD_CLOEXEC);
#endif