** Part of fix for bug #546397
authorMilan Crha <mcrha@redhat.com>
Wed, 6 Aug 2008 09:17:47 +0000 (09:17 +0000)
committerMilan Crha <mcrha@src.gnome.org>
Wed, 6 Aug 2008 09:17:47 +0000 (09:17 +0000)
2008-08-06  Milan Crha  <mcrha@redhat.com>

** Part of fix for bug #546397

* camel/camel-store.c: (construct): Do not use NULL in g_file_test.
* camel/camel-folder-search.c: (read_uid_callback): Cast to right type.
* camel/camel-folder-summary.c: (camel_folder_summary_remove_range):
Do not leak objects from loaded_infos array.

* camel/providers/nntp/camel-nntp-folder.c: (nntp_folder_search_free):
Guard access to 'search' member with its lock.

svn path=/trunk/; revision=9274

camel/ChangeLog
camel/camel-folder-search.c
camel/camel-folder-summary.c
camel/camel-store.c
camel/providers/nntp/ChangeLog
camel/providers/nntp/camel-nntp-folder.c

index c720f4b..8ba3a89 100644 (file)
@@ -1,3 +1,12 @@
+2008-08-06  Milan Crha  <mcrha@redhat.com>
+
+       ** Part of fix for bug #546397
+
+       * camel-store.c: (construct): Do not use NULL in g_file_test.
+       * camel-folder-search.c: (read_uid_callback): Cast to right type.
+       * camel-folder-summary.c: (camel_folder_summary_remove_range):
+       Do not leak objects from loaded_infos array.
+
 2008-08-05  Chenthill Palanisamy  <pchenthill@novell.com>
 
        Fixes part of #533823
index 8b8e589..d4e0689 100644 (file)
@@ -1414,6 +1414,6 @@ read_uid_callback (void * ref, int ncol, char ** cols, char **name)
 
        matches = (GPtrArray *) ref;
 
-       g_ptr_array_add (matches, (GFunc) camel_pstring_strdup (cols [0]));
+       g_ptr_array_add (matches, (gpointer) camel_pstring_strdup (cols [0]));
        return 0;
 }
index a5762e7..4ed71ea 100644 (file)
@@ -2157,10 +2157,15 @@ camel_folder_summary_remove_range (CamelFolderSummary *s, int start, int end)
 
                for (i = start; i < end; i++) {
                        const char *uid = s->uids->pdata[i];
+                       gpointer olduid, oldinfo;
 
+                       /* the uid will be freed below and will not be used because of changing size of the s->uids array */
                        uids = g_slist_prepend (uids, (gpointer) uid);
 
-                       g_hash_table_remove(s->loaded_infos, uid);
+                       if (g_hash_table_lookup_extended (s->loaded_infos, uid, &olduid, &oldinfo)) {
+                               camel_message_info_free (oldinfo);
+                               g_hash_table_remove (s->loaded_infos, uid);
+                       }
                }
                camel_exception_init (&ex);
 
index fc7b8db..9446a72 100644 (file)
@@ -206,7 +206,7 @@ construct (CamelService *service, CamelSession *session,
           CamelException *ex)
 {
        CamelStore *store = CAMEL_STORE(service);
-       char *store_db_path;
+       char *store_db_path, *store_path = NULL;
 
        parent_class->construct(service, session, provider, url, ex);
        if (camel_exception_is_set (ex))
@@ -214,19 +214,20 @@ construct (CamelService *service, CamelSession *session,
 
        store_db_path = g_build_filename (service->url->path, CAMEL_DB_FILE, NULL);
 
-       if (strlen (store_db_path) < 2) {
-               char *store_path = camel_session_get_storage_path (session, service, ex);
+       if (!service->url->path || strlen (store_db_path) < 2) {
+               store_path = camel_session_get_storage_path (session, service, ex);
 
                g_free (store_db_path);
                store_db_path = g_build_filename (store_path, CAMEL_DB_FILE, NULL);
-               g_free (store_path);
        }
 
-       if (!g_file_test(service->url->path, G_FILE_TEST_EXISTS)) {
+       if (!g_file_test (service->url->path ? service->url->path : store_path, G_FILE_TEST_EXISTS)) {
                /* Cache might be blown. Recreate. */
-               g_mkdir_with_parents (service->url->path, S_IRWXU);
+               g_mkdir_with_parents (service->url->path ? service->url->path : store_path, S_IRWXU);
        }
 
+       g_free (store_path);
+
        store->cdb = camel_db_open (store_db_path, ex);
        printf("store_db_path %s\n", store_db_path);
        if (camel_exception_is_set (ex)) {
index 5219ccb..e78c12d 100644 (file)
@@ -1,3 +1,10 @@
+2008-08-06  Milan Crha  <mcrha@redhat.com>
+
+       ** Part of fix for bug #546397
+
+       * camel-nntp-folder.c: (nntp_folder_search_free):
+       Guard access to 'search' member with its lock.
+
 2008-08-01  Matthew Barnes  <mbarnes@redhat.com>
 
        * camel-nntp-store-summary.c:
index 763baef..f561b1f 100644 (file)
@@ -300,8 +300,10 @@ static void
 nntp_folder_search_free (CamelFolder *folder, GPtrArray *result)
 {
        CamelNNTPFolder *nntp_folder = CAMEL_NNTP_FOLDER (folder);
-       
+
+       CAMEL_NNTP_FOLDER_LOCK(nntp_folder, search_lock);
        camel_folder_search_free_result (nntp_folder->search, result);
+       CAMEL_NNTP_FOLDER_UNLOCK(nntp_folder, search_lock);
 }
 
 static void