diff src/lib-storage/index/index-sort-string.c @ 8070:7e3590da43a9 HEAD

sort indexes: One more assert-crashfix when renumbering sort IDs.
author Timo Sirainen <tss@iki.fi>
date Tue, 05 Aug 2008 11:24:29 -0400
parents 2621f6f10c2e
children b3fb8215a339
line wrap: on
line diff
--- a/src/lib-storage/index/index-sort-string.c	Mon Aug 04 20:34:35 2008 -0400
+++ b/src/lib-storage/index/index-sort-string.c	Tue Aug 05 11:24:29 2008 -0400
@@ -516,11 +516,14 @@
 		/* we most likely don't have enough space. we have to
 		   renumber some of the existing sort IDs. do this by
 		   widening the area we're giving sort IDs. */
-		if (left_idx > 0) {
-			left_sort_id = nodes[--left_idx].sort_id;
-			if (left_sort_id == 0) {
-				i_assert(left_idx == 0);
-				left_sort_id = 1;
+		while (left_idx > 0) {
+			if (nodes[--left_idx].sort_id != left_sort_id) {
+				left_sort_id = nodes[left_idx].sort_id;
+				if (left_sort_id == 0) {
+					i_assert(left_idx == 0);
+					left_sort_id = 1;
+				}
+				break;
 			}
 		}