[neon/backports-focal/xdg-desktop-portal/Neon/unstable] src: open-uri: avoid criticals when app to open does not exist

Bastien Nocera null at kde.org
Wed Jan 13 06:32:43 GMT 2021


Git commit c41efbe598918fedf01d69f65b581cfbf107b00b by Bastien Nocera, on behalf of Michael Catanzaro.
Committed on 07/05/2020 at 09:55.
Pushed by ash into branch 'Neon/unstable'.

open-uri: avoid criticals when app to open does not exist

If g_desktop_app_info_new() returns NULL, then the desired desktop file
does not exist. Simply return FALSE in this case instead of trying to
use it.

See: #480

M  +7    -0    src/open-uri.c

https://invent.kde.org/neon/backports-focal/xdg-desktop-portal/commit/c41efbe598918fedf01d69f65b581cfbf107b00b

diff --git a/src/open-uri.c b/src/open-uri.c
index c081a6b..bb63478 100644
--- a/src/open-uri.c
+++ b/src/open-uri.c
@@ -235,6 +235,13 @@ launch_application_with_uri (const char *choice_id,
   g_autofree char *ruri = NULL;
   GList uris;
 
+  if (info == NULL)
+    {
+      g_debug ("Cannot launch %s because desktop file does not exist", desktop_id);
+      g_set_error (error, XDG_DESKTOP_PORTAL_ERROR, XDG_DESKTOP_PORTAL_ERROR_NOT_FOUND, "Desktop file %s does not exist", desktop_id);
+      return FALSE;
+    }
+
   g_debug ("Launching %s %s", choice_id, uri);
 
   if (is_sandboxed (info) && is_file_uri (uri))



More information about the Neon-commits mailing list