[evolution-ews] ews_store_subscribe_folder_sync: Turn two runtime warnings into regular errors



commit 0786b7a993a41414c720d5d1115ae898ddc2eb12
Author: Milan Crha <mcrha redhat com>
Date:   Mon Oct 3 11:06:59 2022 +0200

    ews_store_subscribe_folder_sync: Turn two runtime warnings into regular errors
    
    These should not be triggered, but just in case they would, make sure
    the held lock is released before returning from the function, to avoid
    a deadlock in the future.

 src/EWS/camel/camel-ews-store.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/src/EWS/camel/camel-ews-store.c b/src/EWS/camel/camel-ews-store.c
index 6b2ab320..6908130a 100644
--- a/src/EWS/camel/camel-ews-store.c
+++ b/src/EWS/camel/camel-ews-store.c
@@ -3688,13 +3688,24 @@ ews_store_subscribe_folder_sync (CamelSubscribable *subscribable,
        }
 
        fid = e_ews_folder_get_id (folder);
-
-       g_return_val_if_fail (fid != NULL, FALSE);
+       if (!fid) {
+               g_mutex_unlock (&ews_store->priv->get_finfo_lock);
+               g_set_error (
+                       error, CAMEL_STORE_ERROR, CAMEL_STORE_ERROR_NO_FOLDER,
+                       _("Cannot subscribe folder ā€œ%sā€, folder ID not found"), folder_name);
+               return FALSE;
+       }
 
        if (camel_ews_store_summary_has_folder (ews_store->summary, EWS_PUBLIC_FOLDER_ROOT_ID)) {
                gchar *parent_name = camel_ews_store_summary_get_folder_name (ews_store->summary, 
EWS_PUBLIC_FOLDER_ROOT_ID, NULL);
 
-               g_return_val_if_fail (parent_name != NULL, FALSE);
+               if (!parent_name) {
+                       g_mutex_unlock (&ews_store->priv->get_finfo_lock);
+                       g_set_error (
+                               error, CAMEL_STORE_ERROR, CAMEL_STORE_ERROR_NO_FOLDER,
+                               _("Cannot subscribe folder ā€œ%sā€, public folder root not found"), folder_name);
+                       return FALSE;
+               }
 
                tmp = g_strconcat (parent_name, "/", e_ews_folder_get_escaped_name (folder), NULL);
                g_free (parent_name);


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