[evolution-data-server] Bug #673817 - Crash in e_book_backend_file_dispose()
- From: Milan Crha <mcrha src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server] Bug #673817 - Crash in e_book_backend_file_dispose()
- Date: Mon, 4 Jun 2012 12:10:11 +0000 (UTC)
commit 0511ffe85e34114f56f5cdd606836f869117828a
Author: Milan Crha <mcrha redhat com>
Date: Mon Jun 4 14:09:19 2012 +0200
Bug #673817 - Crash in e_book_backend_file_dispose()
addressbook/backends/file/e-book-backend-file.c | 65 ++++++++++++++---------
1 files changed, 40 insertions(+), 25 deletions(-)
---
diff --git a/addressbook/backends/file/e-book-backend-file.c b/addressbook/backends/file/e-book-backend-file.c
index faff8da..79194c7 100644
--- a/addressbook/backends/file/e-book-backend-file.c
+++ b/addressbook/backends/file/e-book-backend-file.c
@@ -264,7 +264,8 @@ maybe_delete_uri (EBookBackendFile *bf,
/* If the file is in our path it belongs to us and we need to delete it.
*/
- if (!strncmp (bf->priv->photo_dirname, filename, strlen (bf->priv->photo_dirname))) {
+ if (bf->priv->photo_dirname &&
+ !strncmp (bf->priv->photo_dirname, filename, strlen (bf->priv->photo_dirname))) {
d(g_print ("Deleting uri file: %s\n", filename));
@@ -483,7 +484,7 @@ is_backend_owned_uri (EBookBackendFile *bf,
dirname = g_path_get_dirname (filename);
- owned_uri = (strcmp (dirname, bf->priv->photo_dirname) == 0);
+ owned_uri = bf->priv->photo_dirname && (strcmp (dirname, bf->priv->photo_dirname) == 0);
g_free (filename);
g_free (dirname);
@@ -1882,6 +1883,13 @@ e_book_backend_file_open (EBookBackendSync *backend,
registry = e_book_backend_get_registry (E_BOOK_BACKEND (backend));
dirname = e_book_backend_file_extract_path_from_source (
registry, source, GET_PATH_DB_DIR);
+
+ if (!g_file_test (dirname, G_FILE_TEST_IS_DIR)) {
+ g_free (dirname);
+ g_propagate_error (perror, EDB_ERROR (NO_SUCH_BOOK));
+ return;
+ }
+
filename = g_build_filename (dirname, "addressbook.db", NULL);
db_error = e_db3_utils_maybe_recover (filename);
@@ -2150,6 +2158,9 @@ remove_photos (const gchar *dirname)
{
GDir *dir;
+ if (!dirname)
+ return;
+
dir = g_dir_open (dirname, 0, NULL);
if (dir) {
const gchar *name;
@@ -2186,21 +2197,23 @@ e_book_backend_file_remove (EBookBackendSync *backend,
g_object_unref (bf->priv->sqlitedb);
bf->priv->sqlitedb = NULL;
- dir = g_dir_open (bf->priv->dirname, 0, NULL);
- if (dir) {
- const gchar *name;
-
- while ((name = g_dir_read_name (dir))) {
- if (select_changes (name)) {
- gchar *full_path = g_build_filename (bf->priv->dirname, name, NULL);
- if (g_unlink (full_path) == -1) {
- g_warning ("failed to remove change db `%s': %s", full_path, g_strerror (errno));
+ if (bf->priv->dirname) {
+ dir = g_dir_open (bf->priv->dirname, 0, NULL);
+ if (dir) {
+ const gchar *name;
+
+ while ((name = g_dir_read_name (dir))) {
+ if (select_changes (name)) {
+ gchar *full_path = g_build_filename (bf->priv->dirname, name, NULL);
+ if (g_unlink (full_path) == -1) {
+ g_warning ("failed to remove change db `%s': %s", full_path, g_strerror (errno));
+ }
+ g_free (full_path);
}
- g_free (full_path);
}
- }
- g_dir_close (dir);
+ g_dir_close (dir);
+ }
}
/* Remove photos and the photo directory */
@@ -2344,17 +2357,19 @@ e_book_backend_file_dispose (GObject *object)
}
G_LOCK (db_environments);
- genv = g_hash_table_lookup (db_environments, bf->priv->dirname);
- if (genv) {
- genv->ref_count--;
- if (genv->ref_count == 0) {
- genv->env->close (genv->env, 0);
- g_free (genv);
- g_hash_table_remove (db_environments, bf->priv->dirname);
- }
- if (g_hash_table_size (db_environments) == 0) {
- g_hash_table_destroy (db_environments);
- db_environments = NULL;
+ if (bf->priv->dirname) {
+ genv = g_hash_table_lookup (db_environments, bf->priv->dirname);
+ if (genv) {
+ genv->ref_count--;
+ if (genv->ref_count == 0) {
+ genv->env->close (genv->env, 0);
+ g_free (genv);
+ g_hash_table_remove (db_environments, bf->priv->dirname);
+ }
+ if (g_hash_table_size (db_environments) == 0) {
+ g_hash_table_destroy (db_environments);
+ db_environments = NULL;
+ }
}
}
G_UNLOCK (db_environments);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]