Nico Golde:
[apps/madmutt.git] / buffy.c
diff --git a/buffy.c b/buffy.c
index 67800dd..a6436c2 100644 (file)
--- a/buffy.c
+++ b/buffy.c
@@ -135,19 +135,21 @@ int test_new_folder (const char *path)
 
 BUFFY *mutt_find_mailbox (const char *path)
 {
-  BUFFY *tmp = NULL;
   struct stat sb;
   struct stat tmp_sb;
+  int i = 0;
 
   if (stat (path, &sb) != 0)
     return NULL;
 
-  for (tmp = Incoming; tmp; tmp = tmp->next) {
-    if (stat (tmp->path, &tmp_sb) == 0 &&
-        sb.st_dev == tmp_sb.st_dev && sb.st_ino == tmp_sb.st_ino)
-      break;
+  if (!list_empty(Incoming)) {
+    for (i = 0; i < Incoming->length; i++) {
+      if (stat (Incoming->data[i], &tmp_sb) == 0 &&
+          sb.st_dev == tmp_sb.st_dev && sb.st_ino == tmp_sb.st_ino)
+        return ((BUFFY*) Incoming->data[i]);
+    }
   }
-  return tmp;
+  return (NULL);
 }
 
 void mutt_update_mailbox (BUFFY * b)
@@ -588,7 +590,7 @@ int mutt_buffy_list (void)
       first = 0;
     }
   }
-  if (!first && tmp) {
+  if (!first && i < Incoming->length) {
     strncat (buffylist + pos, ", ...", sizeof (buffylist) - 1 - pos);   /* __STRNCAT_CHECKED__ */
   }
   if (!first) {