[gnome-remote-desktop/gnome-42] ctl: Do not crash, when deleting non-existent credentials



commit 8ecbec87ebf77b8d8224ee97f951080ffc3427a1
Author: Pascal Nowack <Pascal Nowack gmx de>
Date:   Tue Aug 2 07:06:30 2022 +0200

    ctl: Do not crash, when deleting non-existent credentials
    
    libsecret apparently does not set an error, if the credentials to
    delete were not found.
    So, also check whether an error was set before assuming that the
    failure of the operation.
    
    Fixes: https://errors.ubuntu.com/problem/5fb98359975eaf2962d46e9073776e3807a9d63c

 src/grd-ctl.c | 34 ++++++++++++++++++++++++++++------
 1 file changed, 28 insertions(+), 6 deletions(-)
---
diff --git a/src/grd-ctl.c b/src/grd-ctl.c
index ddf44df5..f641fb7e 100644
--- a/src/grd-ctl.c
+++ b/src/grd-ctl.c
@@ -117,9 +117,20 @@ grd_store_rdp_credentials (const char  *username,
 static gboolean
 grd_clear_rdp_credentials (GError **error)
 {
-  return secret_password_clear_sync (GRD_RDP_CREDENTIALS_SCHEMA,
-                                     NULL, error,
-                                     NULL);
+  g_autoptr (GError) local_error = NULL;
+
+  secret_password_clear_sync (GRD_RDP_CREDENTIALS_SCHEMA,
+                              NULL, &local_error,
+                              NULL);
+  if (local_error)
+    {
+      g_propagate_error (error, g_steal_pointer (&local_error));
+      return FALSE;
+    }
+  else
+    {
+      return TRUE;
+    }
 }
 
 static gboolean
@@ -305,9 +316,20 @@ vnc_clear_credentials (int      argc,
                        char   **argv,
                        GError **error)
 {
-  return secret_password_clear_sync (GRD_VNC_PASSWORD_SCHEMA,
-                                     NULL, error,
-                                     NULL);
+  g_autoptr (GError) local_error = NULL;
+
+  secret_password_clear_sync (GRD_VNC_PASSWORD_SCHEMA,
+                              NULL, &local_error,
+                              NULL);
+  if (local_error)
+    {
+      g_propagate_error (error, g_steal_pointer (&local_error));
+      return FALSE;
+    }
+  else
+    {
+      return TRUE;
+    }
 }
 
 static gboolean


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