aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-01-19 08:18:53 +0000
committerhiro <hiro@ee746299-78ed-0310-b773-934348b2243d>2005-01-19 08:18:53 +0000
commit670d6b52fe5910aa6fdc3c4a510a37ea6e2b00dc (patch)
treeb1dc5bf84d5386dcf7f34571224a2a6ee544ca67 /src
parentb303c834f7f1fcf25035d709135b2a114c1110c0 (diff)
fixed crash when opening 0-numbered message.
git-svn-id: svn://sylpheed.sraoss.jp/sylpheed/trunk@20 ee746299-78ed-0310-b773-934348b2243d
Diffstat (limited to 'src')
-rw-r--r--src/messageview.c2
-rw-r--r--src/mh.c8
-rw-r--r--src/procmsg.c4
-rw-r--r--src/utils.c12
4 files changed, 14 insertions, 12 deletions
diff --git a/src/messageview.c b/src/messageview.c
index 4691d52f..707da43d 100644
--- a/src/messageview.c
+++ b/src/messageview.c
@@ -427,6 +427,8 @@ gint messageview_show(MessageView *messageview, MsgInfo *msginfo,
if (messageview->msginfo != msginfo) {
procmsg_msginfo_free(messageview->msginfo);
messageview->msginfo = procmsg_msginfo_get_full_info(msginfo);
+ if (!messageview->msginfo)
+ messageview->msginfo = procmsg_msginfo_copy(msginfo);
}
headerview_show(messageview->headerview, messageview->msginfo);
diff --git a/src/mh.c b/src/mh.c
index 7c7e5bd3..60ada344 100644
--- a/src/mh.c
+++ b/src/mh.c
@@ -715,7 +715,7 @@ static gint mh_scan_folder_full(Folder *folder, FolderItem *item,
folder->ui_func(folder, item, folder->ui_func_data);
while ((d = readdir(dp)) != NULL) {
- if ((num = to_number(d->d_name)) >= 0 &&
+ if ((num = to_number(d->d_name)) > 0 &&
dirent_is_regular_file(d)) {
n_msg++;
if (max < num)
@@ -974,7 +974,7 @@ static GSList *mh_get_uncached_msgs(GHashTable *msg_table, FolderItem *item)
if (msg_table) {
while ((d = readdir(dp)) != NULL) {
- if ((num = to_number(d->d_name)) < 0) continue;
+ if ((num = to_number(d->d_name)) <= 0) continue;
msginfo = g_hash_table_lookup
(msg_table, GUINT_TO_POINTER(num));
@@ -997,7 +997,7 @@ static GSList *mh_get_uncached_msgs(GHashTable *msg_table, FolderItem *item)
} else {
/* discard all previous cache */
while ((d = readdir(dp)) != NULL) {
- if (to_number(d->d_name) < 0) continue;
+ if (to_number(d->d_name) <= 0) continue;
msginfo = mh_parse_msg(d->d_name, item);
if (!msginfo) continue;
@@ -1227,7 +1227,7 @@ static void mh_scan_tree_recursive(FolderItem *item)
}
mh_scan_tree_recursive(new_item);
- } else if (to_number(d->d_name) != -1) n_msg++;
+ } else if (to_number(d->d_name) > 0) n_msg++;
g_free(entry);
g_free(utf8entry);
diff --git a/src/procmsg.c b/src/procmsg.c
index 0328d47a..9b8bcb1f 100644
--- a/src/procmsg.c
+++ b/src/procmsg.c
@@ -262,8 +262,8 @@ GSList *procmsg_read_cache(FolderItem *item, gboolean scan_file)
/* if the message file doesn't exist or is changed,
don't add the data */
- if (type == F_MH && scan_file &&
- folder_item_is_msg_changed(item, msginfo))
+ if ((type == F_MH && scan_file &&
+ folder_item_is_msg_changed(item, msginfo)) || num == 0)
procmsg_msginfo_free(msginfo);
else {
msginfo->folder = item;
diff --git a/src/utils.c b/src/utils.c
index 42b294e1..16602697 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -1950,7 +1950,7 @@ gint remove_numbered_files(const gchar *dir, guint first, guint last)
DIR *dp;
struct dirent *d;
gchar *prev_dir;
- gint fileno;
+ gint file_no;
prev_dir = g_get_current_dir();
@@ -1967,8 +1967,8 @@ gint remove_numbered_files(const gchar *dir, guint first, guint last)
}
while ((d = readdir(dp)) != NULL) {
- fileno = to_number(d->d_name);
- if (fileno >= 0 && first <= fileno && fileno <= last) {
+ file_no = to_number(d->d_name);
+ if (file_no > 0 && first <= file_no && file_no <= last) {
if (is_dir_exist(d->d_name))
continue;
if (unlink(d->d_name) < 0)
@@ -2000,7 +2000,7 @@ gint remove_expired_files(const gchar *dir, guint hours)
struct dirent *d;
struct stat s;
gchar *prev_dir;
- gint fileno;
+ gint file_no;
time_t mtime, now, expire_time;
prev_dir = g_get_current_dir();
@@ -2021,8 +2021,8 @@ gint remove_expired_files(const gchar *dir, guint hours)
expire_time = hours * 60 * 60;
while ((d = readdir(dp)) != NULL) {
- fileno = to_number(d->d_name);
- if (fileno >= 0) {
+ file_no = to_number(d->d_name);
+ if (file_no > 0) {
if (stat(d->d_name, &s) < 0) {
FILE_OP_ERROR(d->d_name, "stat");
continue;