]> git.notmuchmail.org Git - notmuch/blobdiff - lib/message.cc
lib: Clean up error handling in _notmuch_thread_create
[notmuch] / lib / message.cc
index bbac2ffaf87da987b1c7f05244ce1caf801831c1..320901f77eb010a1cab4502c79db6faccbc6d49c 100644 (file)
@@ -788,7 +788,9 @@ notmuch_message_get_tags (notmuch_message_t *message)
      * possible to modify the message tags (which talloc_unlink's the
      * current list from the message) while still iterating because
      * the iterator will keep the current list alive. */
-    talloc_reference (message, message->tag_list);
+    if (!talloc_reference (message, message->tag_list))
+       return NULL;
+
     return tags;
 }
 
@@ -1090,13 +1092,19 @@ notmuch_message_maildir_flags_to_tags (notmuch_message_t *message)
            continue;
 
        flags = strstr (filename, ":2,");
-       if (! flags)
-           continue;
-
-       seen_maildir_info = 1;
-       flags += 3;
-
-       combined_flags = talloc_strdup_append (combined_flags, flags);
+       if (flags) {
+           seen_maildir_info = 1;
+           flags += 3;
+           combined_flags = talloc_strdup_append (combined_flags, flags);
+       } else if (STRNCMP_LITERAL (dir, "new/") == 0) {
+           /* Messages are delivered to new/ with no "info" part, but
+            * they effectively have default maildir flags.  According
+            * to the spec, we should ignore the info part for
+            * messages in new/, but some MUAs (mutt) can set maildir
+            * flags on messages in new/, so we're liberal in what we
+            * accept. */
+           seen_maildir_info = 1;
+       }
     }
 
     /* If none of the filenames have any maildir info field (not even