[xdg-desktop-portal-gnome/wip/rishi/coverity-fixes-01: 2/4] main: Don't assume that environment variables were successfully set




commit f0aa33ccc5b69f1e4a92ce901c3ec150b98b5b17
Author: Debarshi Ray <debarshir gnome org>
Date:   Sat Jul 2 17:13:17 2022 +0200

    main: Don't assume that environment variables were successfully set
    
    Fallout from ab21bc9d9887f90110b843cda3ff73bfc11f0df9 and
    7f6357032d0f7b936242f05b13dab59807a44ebc
    
    https://gitlab.gnome.org/GNOME/xdg-desktop-portal-gnome/-/merge_requests/46

 src/xdg-desktop-portal-gnome.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
---
diff --git a/src/xdg-desktop-portal-gnome.c b/src/xdg-desktop-portal-gnome.c
index f7ef7f9..a6b1eeb 100644
--- a/src/xdg-desktop-portal-gnome.c
+++ b/src/xdg-desktop-portal-gnome.c
@@ -211,8 +211,18 @@ main (int argc, char *argv[])
 
   /* Avoid pointless and confusing recursion */
   g_unsetenv ("GTK_USE_PORTAL");
-  g_setenv ("ADW_DISABLE_PORTAL", "1", TRUE);
-  g_setenv ("GSK_RENDERER", "cairo", TRUE);
+
+  if (G_UNLIKELY (!g_setenv ("ADW_DISABLE_PORTAL", "1", TRUE)))
+    {
+      g_printerr ("Failed to set ADW_DISABLE_PORTAL: %s\n", g_strerror (errno));
+      return 1;
+    }
+
+  if (G_UNLIKELY (!g_setenv ("GSK_RENDERER", "cairo", TRUE)))
+    {
+      g_printerr ("Failed to set GSK_RENDERER: %s\n", g_strerror (errno));
+      return 1;
+    }
 
   gtk_init ();
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]