dovecot: Fixed squat lookup.

dovecot at dovecot.org dovecot at dovecot.org
Sat Feb 16 13:21:45 EET 2008


details:   http://hg.dovecot.org/dovecot/rev/49e91699be7d
changeset: 7248:49e91699be7d
user:      Timo Sirainen <tss at iki.fi>
date:      Sat Feb 16 13:22:10 2008 +0200
description:
Fixed squat lookup.

diffstat:

1 file changed, 6 insertions(+), 6 deletions(-)
src/plugins/fts-squat/squat-trie.c |   12 ++++++------

diffs (30 lines):

diff -r 9137bd313e04 -r 49e91699be7d src/plugins/fts-squat/squat-trie.c
--- a/src/plugins/fts-squat/squat-trie.c	Sat Feb 16 13:21:37 2008 +0200
+++ b/src/plugins/fts-squat/squat-trie.c	Sat Feb 16 13:22:10 2008 +0200
@@ -1800,10 +1800,10 @@ squat_trie_lookup_partial(struct squat_t
 	int ret;
 
 	max_chars = uni_utf8_strlen_n(data, size);
-	if (max_chars > ctx->trie->hdr.partial_len)
-		max_chars = partial_len;
-
-	for (i = 0, char_idx = 0; char_idx < max_chars; char_idx++) {
+	i_assert(max_chars > 0);
+
+	i = 0; char_idx = 0;
+	do {
 		bytelen = 0;
 		for (j = 0; j < partial_len && i+bytelen < size; j++)
 			bytelen += char_lengths[i + bytelen];
@@ -1825,9 +1825,9 @@ squat_trie_lookup_partial(struct squat_t
 			seq_range_array_remove_invert_range(ctx->maybe_uids,
 							    &ctx->tmp_uids2);
 		}
-
 		i += char_lengths[i];
-	}
+		char_idx++;
+	} while (max_chars - char_idx >= partial_len);
 	return 1;
 }
 


More information about the dovecot-cvs mailing list