[evolution-mapi] Bug #668810 - Crash in g_str_hash, mapi_store_delete_folder_sync



commit 8ce3734621c842edab8c0322a13b0aefcfbab33a
Author: Milan Crha <mcrha redhat com>
Date:   Thu Mar 1 09:07:02 2012 +0100

    Bug #668810 - Crash in g_str_hash, mapi_store_delete_folder_sync

 src/camel/camel-mapi-folder.c |    4 ++--
 src/camel/camel-mapi-store.c  |   33 ++++++++++++++++++++++++++-------
 2 files changed, 28 insertions(+), 9 deletions(-)
---
diff --git a/src/camel/camel-mapi-folder.c b/src/camel/camel-mapi-folder.c
index ce76ee6..512aae8 100644
--- a/src/camel/camel-mapi-folder.c
+++ b/src/camel/camel-mapi-folder.c
@@ -1856,10 +1856,10 @@ mapi_folder_transfer_messages_to_sync (CamelFolder *source,
 				"%s", err ? err->message : _("Unknown error"));
 		g_clear_error (&err);
 		success = FALSE;
-	} else {
+	} else if (delete_originals) {
 		changes = camel_folder_change_info_new ();
 
-		for (i=0; i < uids->len; i++) {
+		for (i = 0; i < uids->len; i++) {
 			camel_folder_summary_remove_uid (source->summary, uids->pdata[i]);
 			camel_folder_change_info_remove_uid (changes, uids->pdata[i]);
 		}
diff --git a/src/camel/camel-mapi-store.c b/src/camel/camel-mapi-store.c
index 1a967d5..677cda1 100644
--- a/src/camel/camel-mapi-store.c
+++ b/src/camel/camel-mapi-store.c
@@ -1371,10 +1371,23 @@ mapi_store_delete_folder_sync (CamelStore *store,
 			return FALSE;
 		}
 
-		return TRUE;
+		g_set_error_literal (
+			error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE,
+			_("Cannot delete MAPI folders in offline mode"));
+
+		return FALSE;
 	}
 
 	folder_id = g_hash_table_lookup (priv->name_hash, folder_name);
+	if (!folder_id) {
+		camel_service_unlock (CAMEL_SERVICE (store), CAMEL_SERVICE_REC_CONNECT_LOCK);
+		g_set_error (
+			error, CAMEL_SERVICE_ERROR,
+			CAMEL_SERVICE_ERROR_UNAVAILABLE,
+			_("Cannot find folder '%s'"), folder_name);
+		return FALSE;
+	}
+
 	e_mapi_util_mapi_id_from_string (folder_id, &folder_fid);
 
 	msi = (CamelMapiStoreInfo *) camel_mapi_store_summary_get_folder_id (mapi_store->summary, folder_fid);
@@ -1391,12 +1404,14 @@ mapi_store_delete_folder_sync (CamelStore *store,
 		status = FALSE;
 
 	if (status) {
-		success = mapi_forget_folder (mapi_store,folder_name,error);
+		success = mapi_forget_folder (mapi_store, folder_name, error);
 
-		/* remove from name_cache at the end, because the folder_id is from there */
-		/*g_hash_table_remove (priv->parent_hash, folder_id);*/
-		g_hash_table_remove (priv->id_hash, folder_id);
-		g_hash_table_remove (priv->name_hash, folder_name);
+		if (success) {
+			/* remove from name_cache at the end, because the folder_id is from there */
+			/*g_hash_table_remove (priv->parent_hash, folder_id);*/
+			g_hash_table_remove (priv->id_hash, folder_id);
+			g_hash_table_remove (priv->name_hash, folder_name);
+		}
 	} else {
 		success = FALSE;
 
@@ -1459,7 +1474,11 @@ mapi_store_rename_folder_sync (CamelStore *store,
 			return FALSE;
 		}
 
-		return TRUE;
+		g_set_error_literal (
+			error, CAMEL_SERVICE_ERROR, CAMEL_SERVICE_ERROR_UNAVAILABLE,
+			_("Cannot rename MAPI folders in offline mode"));
+
+		return FALSE;
 	}
 
 	/* Need a full name of a folder */



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