aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEttore Perazzoli <ettore@src.gnome.org>2000-05-07 10:22:08 +0800
committerEttore Perazzoli <ettore@src.gnome.org>2000-05-07 10:22:08 +0800
commitfe27ab117972b1d98792ee0c78abce0a3c4a0acb (patch)
treee62ce3cab9a074917276ffb2ab3ee91e56deb11d
parent3219faad0c583cf44add809ded9183ccc9c4f302 (diff)
downloadgsoc2013-evolution-fe27ab117972b1d98792ee0c78abce0a3c4a0acb.tar.gz
gsoc2013-evolution-fe27ab117972b1d98792ee0c78abce0a3c4a0acb.tar.zst
gsoc2013-evolution-fe27ab117972b1d98792ee0c78abce0a3c4a0acb.zip
Portability fix (use `readdir()', not `readdir_r()'). Also, be safer
about NULL objects when destroying the shell or the shortcuts. svn path=/trunk/; revision=2850
-rw-r--r--shell/ChangeLog9
-rw-r--r--shell/e-local-storage.c17
-rw-r--r--shell/e-shell.c11
-rw-r--r--shell/e-shortcut.c10
-rw-r--r--shell/e-shortcuts.c7
5 files changed, 34 insertions, 20 deletions
diff --git a/shell/ChangeLog b/shell/ChangeLog
index 891872d5ba..ec8efccb7e 100644
--- a/shell/ChangeLog
+++ b/shell/ChangeLog
@@ -1,5 +1,14 @@
2000-05-06 Ettore Perazzoli <ettore@helixcode.com>
+ * e-shortcuts.c (destroy): Be safer about NULL objects.
+
+ * e-shell.c (destroy): Be safer about NULL objects.
+
+ * e-local-storage.c (load_folders): Use `readdir()', not
+ `readdir_r()'.
+
+2000-05-06 Ettore Perazzoli <ettore@helixcode.com>
+
* main.c (init_corba) [! USING_OAF]: We have no options no
popt context.
diff --git a/shell/e-local-storage.c b/shell/e-local-storage.c
index d4d30d67c5..f559d30f34 100644
--- a/shell/e-local-storage.c
+++ b/shell/e-local-storage.c
@@ -150,7 +150,6 @@ load_folders (ELocalStorage *local_storage,
{
DIR *dir;
char *subfolder_directory_path;
- struct dirent *dirent;
if (parent_path == NULL) {
/* On the top level, we don't have any folders and, consequently, no
@@ -181,24 +180,21 @@ load_folders (ELocalStorage *local_storage,
return FALSE;
}
- dirent = g_malloc (sizeof (struct dirent) + MAXPATHLEN + 1);
-
while (1) {
struct stat file_stat;
- struct dirent *result;
+ struct dirent *dirent;
char *file_path;
char *new_path;
- if (readdir_r (dir, dirent, &result) != 0)
- break;
- if (result == NULL)
+ dirent = readdir (dir);
+ if (dirent == NULL)
break;
- if (strcmp (result->d_name, ".") == 0 || strcmp (result->d_name, "..") == 0)
+ if (strcmp (dirent->d_name, ".") == 0 || strcmp (dirent->d_name, "..") == 0)
continue;
file_path = g_concat_dir_and_file (subfolder_directory_path,
- result->d_name);
+ dirent->d_name);
if (stat (file_path, &file_stat) < 0) {
g_free (file_path);
@@ -209,7 +205,7 @@ load_folders (ELocalStorage *local_storage,
continue;
}
- new_path = g_concat_dir_and_file (path, result->d_name);
+ new_path = g_concat_dir_and_file (path, dirent->d_name);
load_folders (local_storage, path, new_path, file_path);
@@ -217,7 +213,6 @@ load_folders (ELocalStorage *local_storage,
g_free (new_path);
}
- g_free (dirent);
closedir (dir);
g_free (subfolder_directory_path);
diff --git a/shell/e-shell.c b/shell/e-shell.c
index 6c225cdf49..dbde28f890 100644
--- a/shell/e-shell.c
+++ b/shell/e-shell.c
@@ -91,9 +91,14 @@ destroy (GtkObject *object)
shell = E_SHELL (object);
priv = shell->priv;
- gtk_object_unref (GTK_OBJECT (priv->storage_set));
- gtk_object_unref (GTK_OBJECT (priv->shortcuts));
- gtk_object_unref (GTK_OBJECT (priv->folder_type_repository));
+ if (priv->storage_set != NULL)
+ gtk_object_unref (GTK_OBJECT (priv->storage_set));
+
+ if (priv->shortcuts != NULL)
+ gtk_object_unref (GTK_OBJECT (priv->shortcuts));
+
+ if (priv->folder_type_repository != NULL)
+ gtk_object_unref (GTK_OBJECT (priv->folder_type_repository));
g_free (priv);
diff --git a/shell/e-shortcut.c b/shell/e-shortcut.c
index ed09abe932..532f38b175 100644
--- a/shell/e-shortcut.c
+++ b/shell/e-shortcut.c
@@ -33,8 +33,9 @@ static void
es_destroy (GtkObject *object)
{
EShortcut *ef = E_SHORTCUT (object);
-
- gtk_object_unref (GTK_OBJECT (ef->efolder));
+
+ if (ef->efolder != NULL)
+ gtk_object_unref (GTK_OBJECT (ef->efolder));
shortcut_parent_class->destroy (object);
}
@@ -57,8 +58,9 @@ esg_destroy (GtkObject *object)
for (i = 0; i < shortcut_count; i++){
EShortcut *es = g_array_index (efg->shortcuts, EShortcut *, i);
-
- gtk_object_unref (GTK_OBJECT (es));
+
+ if (es != NULL)
+ gtk_object_unref (GTK_OBJECT (es));
}
g_array_free (efg->shortcuts, TRUE);
diff --git a/shell/e-shortcuts.c b/shell/e-shortcuts.c
index 09474e9491..0fa7b27f61 100644
--- a/shell/e-shortcuts.c
+++ b/shell/e-shortcuts.c
@@ -379,8 +379,11 @@ destroy (GtkObject *object)
shortcuts = E_SHORTCUTS (object);
priv = shortcuts->priv;
- gtk_object_unref (GTK_OBJECT (priv->storage_set));
- gtk_object_unref (GTK_OBJECT (priv->folder_type_repository));
+ if (priv->storage_set != NULL)
+ gtk_object_unref (GTK_OBJECT (priv->storage_set));
+
+ if (priv->folder_type_repository != NULL)
+ gtk_object_unref (GTK_OBJECT (priv->folder_type_repository));
unload_shortcuts (shortcuts);