[Dovecot] strange problem

Timo Sirainen tss at iki.fi
Mon Jun 23 20:09:34 EEST 2003


On Mon, 2003-06-23 at 19:31, tom hensel wrote:
> Jun 23 16:28:15 host imap(user): file mail-index.c: line 619 (mail_index_lookup_uid_range): assertion failed: (first_uid > 0 && last_uid > 0)

Whops. Fetching messages in empty mailbox caused some crashes.

diff -u -r1.17 index-messageset.c
--- src/lib-storage/index/index-messageset.c    23 Apr 2003 14:11:17 -0000     1.17
+++ src/lib-storage/index/index-messageset.c    23 Jun 2003 17:07:59 -0000
@@ -176,6 +176,12 @@
                return FALSE;
        }
 
+       if (ctx->messages_count == 0 && !ctx->uidset &&
+           num == (unsigned int)-1) {
+               ctx->error = "No messages in mailbox";
+               return FALSE;
+       }
+
        return TRUE;
 }
 
@@ -187,11 +193,17 @@
                struct mail_index_record *rec;
 
                rec = ctx->index->lookup(ctx->index, ctx->messages_count);
-               ctx->num1 = rec == NULL ? 0 : rec->uid;
+               if (rec == NULL)
+                       return 1;
+
+               ctx->num1 = rec->uid;
        }
 
        if (ctx->num2 == (unsigned int)-1) {
                ctx->num2 = ctx->index->header->next_uid-1;
+
+               if (ctx->num2 == 0)
+                       return 1;
 
                /* num1 might actually be larger, check */
                if (ctx->num1 > ctx->num2) {



More information about the dovecot mailing list