diff options
author | Jeffrey Stedfast <fejj@ximian.com> | 2001-02-23 05:40:26 +0800 |
---|---|---|
committer | Jeffrey Stedfast <fejj@src.gnome.org> | 2001-02-23 05:40:26 +0800 |
commit | e939da9df48b7e4992de4df915e7832803f8fa12 (patch) | |
tree | 2baa5274b6b5601a6560bde5d15f0d7faf6d956b /mail/mail-vtrash.c | |
parent | 09515df40565b84e1fdcafce80015b51c0984567 (diff) | |
download | gsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.tar.gz gsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.tar.zst gsoc2013-evolution-e939da9df48b7e4992de4df915e7832803f8fa12.zip |
Fixed memory corruption bug.
2001-02-22 Jeffrey Stedfast <fejj@ximian.com>
* openpgp-utils.c (openpgp_verify): Fixed memory corruption bug.
* mail-format.c (try_inline_pgp_sig): Check to make sure the
validity isn't NULL.
(handle_multipart_signed): Check for NULL validities.
2001-02-21 Jeffrey Stedfast <fejj@ximian.com>
* mail-tools.c (mail_tool_uri_to_folder): Protect against NULL
uri's.
* mail-vtrash.c: Do mutex locking on the global hash table - this
should clear up some segfaults ;-)
* mail-config-druid.c (druid_finish): Set the 'enabled' member of
the source to TRUE if the URL exists else set to FALSE.
(incoming_type_changed): If the provider chosen is "None" then
gray-out the auto-check widgets and the check-settings, otherwise
sensitize them.
* mail-account-editor.c (construct): Added a few more settings.
(apply_changes): Save the new settings.
* mail-config.c (service_copy): Updated.
(config_read): Read in whether or not the account is enabled.
(mail_config_write): Save if the account is enabled or not.
svn path=/trunk/; revision=8349
Diffstat (limited to 'mail/mail-vtrash.c')
-rw-r--r-- | mail/mail-vtrash.c | 44 |
1 files changed, 31 insertions, 13 deletions
diff --git a/mail/mail-vtrash.c b/mail/mail-vtrash.c index 134ce558f5..ff76756e73 100644 --- a/mail/mail-vtrash.c +++ b/mail/mail-vtrash.c @@ -42,7 +42,11 @@ #define d(x) +#define VTRASH_LOCK(x) pthread_mutex_lock(&x) +#define VTRASH_UNLOCK(x) pthread_mutex_unlock(&x) + static GHashTable *vtrash_hash = NULL; +static pthread_mutex_t vtrash_hash_lock = PTHREAD_MUTEX_INITIALIZER; extern char *evolution_dir; extern CamelSession *session; @@ -51,17 +55,20 @@ extern CamelSession *session; CamelFolder * vtrash_uri_to_folder (const char *uri, CamelException *ex) { - CamelFolder *folder; + CamelFolder *folder = NULL; - if (!vtrash_hash) - return NULL; + g_return_val_if_fail (uri != NULL, NULL); if (strncmp (uri, "vtrash:", 7)) - return NULL; + return NULL; - folder = g_hash_table_lookup (vtrash_hash, uri); - - camel_object_ref (CAMEL_OBJECT (folder)); + VTRASH_LOCK (vtrash_hash_lock); + if (vtrash_hash) { + folder = g_hash_table_lookup (vtrash_hash, uri); + + camel_object_ref (CAMEL_OBJECT (folder)); + } + VTRASH_UNLOCK (vtrash_hash_lock); return folder; } @@ -76,9 +83,12 @@ vtrash_add (CamelStore *store, CamelFolder *folder, const char *store_uri, const uri = g_strdup_printf ("vtrash:%s", store_uri); + VTRASH_LOCK (vtrash_hash_lock); + if (!vtrash_hash) { vtrash_hash = g_hash_table_new (g_str_hash, g_str_equal); } else if (g_hash_table_lookup (vtrash_hash, uri) != NULL) { + VTRASH_UNLOCK (vtrash_hash_lock); g_free (uri); return; } @@ -90,6 +100,7 @@ vtrash_add (CamelStore *store, CamelFolder *folder, const char *store_uri, const } if (!storage) { + VTRASH_UNLOCK (vtrash_hash_lock); g_free (uri); return; } @@ -99,10 +110,12 @@ vtrash_add (CamelStore *store, CamelFolder *folder, const char *store_uri, const "mail", uri, name, FALSE); gtk_object_unref (GTK_OBJECT (storage)); + g_free (path); + g_hash_table_insert (vtrash_hash, uri, folder); camel_object_ref (CAMEL_OBJECT (folder)); - g_free (path); + VTRASH_UNLOCK (vtrash_hash_lock); } struct _get_trash_msg { @@ -138,7 +151,9 @@ create_trash_vfolder (const char *name, GPtrArray *urls, CamelException *ex) foldername = g_strdup ("mbox?(match-all (system-flag \"Deleted\"))"); /* we dont have indexing on vfolders */ - folder = mail_tool_get_folder_from_urlname (storeuri, foldername, CAMEL_STORE_FOLDER_CREATE|CAMEL_STORE_VEE_FOLDER_AUTO, ex); + folder = mail_tool_get_folder_from_urlname (storeuri, foldername, + CAMEL_STORE_FOLDER_CREATE | CAMEL_STORE_VEE_FOLDER_AUTO, + ex); g_free (foldername); g_free (storeuri); if (camel_exception_is_set (ex)) @@ -284,9 +299,12 @@ free_folder (gpointer key, gpointer value, gpointer data) void vtrash_cleanup (void) { - if (!vtrash_hash) - return; + VTRASH_LOCK (vtrash_hash_lock); + + if (vtrash_hash) { + g_hash_table_foreach (vtrash_hash, free_folder, NULL); + g_hash_table_destroy (vtrash_hash); + } - g_hash_table_foreach (vtrash_hash, free_folder, NULL); - g_hash_table_destroy (vtrash_hash); + VTRASH_UNLOCK (vtrash_hash_lock); } |