Index: camel/camel-store.c
===================================================================
--- camel/camel-store.c	(revision 9264)
+++ camel/camel-store.c	(working copy)
@@ -206,7 +206,7 @@ construct (CamelService *service, CamelS
 	   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))
@@ -215,18 +215,19 @@ construct (CamelService *service, CamelS
 	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);
+		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: camel/providers/nntp/ChangeLog
===================================================================
--- camel/providers/nntp/ChangeLog	(revision 9264)
+++ camel/providers/nntp/ChangeLog	(working copy)
@@ -1,3 +1,10 @@
+2008-08-05  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: camel/providers/nntp/camel-nntp-folder.c
===================================================================
--- camel/providers/nntp/camel-nntp-folder.c	(revision 9264)
+++ camel/providers/nntp/camel-nntp-folder.c	(working copy)
@@ -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           
Index: camel/camel-folder-search.c
===================================================================
--- camel/camel-folder-search.c	(revision 9264)
+++ camel/camel-folder-search.c	(working copy)
@@ -1414,6 +1414,6 @@ read_uid_callback (void * ref, int ncol,
 
 	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: camel/ChangeLog
===================================================================
--- camel/ChangeLog	(revision 9264)
+++ camel/ChangeLog	(working copy)
@@ -1,3 +1,12 @@
+2008-08-05  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):
+	Make copy of the UID with camel_pstring_strdup.
+
 2008-08-05  Srinivasa Ragavan  <sragavan@novell.com>
 
 	* camel/camel-vee-folder.c:
Index: camel/camel-folder-summary.c
===================================================================
--- camel/camel-folder-summary.c	(revision 9264)
+++ camel/camel-folder-summary.c	(working copy)
@@ -2153,7 +2157,7 @@ camel_folder_summary_remove_range (Camel
 		for (i = start; i < end; i++) {
 			const char *uid = s->uids->pdata[i];
 
-			uids = g_slist_prepend (uids, (gpointer) uid);
+			uids = g_slist_prepend (uids, (gpointer) camel_pstring_strdup (uid));
 
 			g_hash_table_remove(s->loaded_infos, uid);
 		}
