[dovecot-cvs] dovecot/src/lib-index mail-index-view.c,1.9,1.10

cras at procontrol.fi cras at procontrol.fi
Wed May 26 02:21:58 EEST 2004


Update of /home/cvs/dovecot/src/lib-index
In directory talvi:/tmp/cvs-serv20571/lib-index

Modified Files:
	mail-index-view.c 
Log Message:
mail_index_lookup_uid_range(): don't crash if we look only UIDs larger than
our next_uid



Index: mail-index-view.c
===================================================================
RCS file: /home/cvs/dovecot/src/lib-index/mail-index-view.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- a/mail-index-view.c	23 May 2004 16:30:24 -0000	1.9
+++ b/mail-index-view.c	25 May 2004 23:21:56 -0000	1.10
@@ -267,6 +267,15 @@
 	if (mail_index_view_lock(view) < 0)
 		return -1;
 
+	if (last_uid >= view->map->hdr->next_uid) {
+		last_uid = view->map->hdr->next_uid-1;
+		if (first_uid > last_uid) {
+			*first_seq_r = 0;
+			*last_seq_r = 0;
+			return 0;
+		}
+	}
+
 	left_idx = 0;
 	*first_seq_r = mail_index_bsearch_uid(view, first_uid, &left_idx, 1);
 	if (*first_seq_r == 0 ||
@@ -280,9 +289,6 @@
 		return 0;
 	}
 
-	if (last_uid >= view->map->hdr->next_uid)
-		last_uid = view->map->hdr->next_uid-1;
-
 	/* optimization - binary lookup only from right side: */
 	*last_seq_r = mail_index_bsearch_uid(view, last_uid, &left_idx, -1);
 	i_assert(*last_seq_r >= *first_seq_r);



More information about the dovecot-cvs mailing list