]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-storage: Clarify that mail_namespace_find_inbox() never returns NULL.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 5 Jul 2016 17:58:29 +0000 (20:58 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Tue, 5 Jul 2016 17:58:29 +0000 (20:58 +0300)
If namespaces==NULL, this function isn't even supposed to be called.

src/lib-storage/mail-namespace.c
src/lib-storage/mail-namespace.h

index 6b8089462624fbf414c37e0526e0c5029628eac5..d6db49b1f7d183820bffad2e2cbfd4c49a3197dc 100644 (file)
@@ -730,8 +730,13 @@ mail_namespace_find_unsubscribable(struct mail_namespace *namespaces,
 struct mail_namespace *
 mail_namespace_find_inbox(struct mail_namespace *namespaces)
 {
-       while ((namespaces->flags & NAMESPACE_FLAG_INBOX_USER) == 0)
+       i_assert(namespaces != NULL);
+
+       /* there should always be an INBOX */
+       while ((namespaces->flags & NAMESPACE_FLAG_INBOX_USER) == 0) {
                namespaces = namespaces->next;
+               i_assert(namespaces != NULL);
+       }
        return namespaces;
 }
 
index ca2e2b37086cf65d2b6c20b5327a7073517a1d49..a789f80b709788f6f7932d6a406beaaed073f807 100644 (file)
@@ -142,7 +142,7 @@ mail_namespace_find_subscribable(struct mail_namespace *namespaces,
 struct mail_namespace *
 mail_namespace_find_unsubscribable(struct mail_namespace *namespaces,
                                   const char *mailbox);
-/* Returns the INBOX namespace, or NULL if there is no such  */
+/* Returns the INBOX namespace. It always exists, so NULL is never returned. */
 struct mail_namespace *
 mail_namespace_find_inbox(struct mail_namespace *namespaces);
 /* Find a namespace with given prefix. */