dovecot-2.2: fts-lucene: Skip returned duplicate results.

dovecot at dovecot.org dovecot at dovecot.org
Tue Mar 11 11:26:49 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/d63b209737be
changeset: 17154:d63b209737be
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Mar 11 13:26:33 2014 +0200
description:
fts-lucene: Skip returned duplicate results.
This caused assert-crash at least when searching from virtual mailbox
because the score array was larger than the actual number of results.

diffstat:

 src/plugins/fts-lucene/lucene-wrapper.cc |  16 ++++++++++------
 1 files changed, 10 insertions(+), 6 deletions(-)

diffs (40 lines):

diff -r a94e1b560a80 -r d63b209737be src/plugins/fts-lucene/lucene-wrapper.cc
--- a/src/plugins/fts-lucene/lucene-wrapper.cc	Tue Mar 11 00:39:27 2014 +0200
+++ b/src/plugins/fts-lucene/lucene-wrapper.cc	Tue Mar 11 13:26:33 2014 +0200
@@ -1271,7 +1271,9 @@
 				break;
 			}
 
-			if (result != NULL) {
+			if (seq_range_array_add(uids_r, uid)) {
+				/* duplicate result */
+			} else if (result != NULL) {
 				if (uid < last_uid)
 					result->scores_sorted = false;
 				last_uid = uid;
@@ -1280,7 +1282,6 @@
 				score->uid = uid;
 				score->score = hits->score(i);
 			}
-			seq_range_array_add(uids_r, uid);
 		}
 		_CLDELETE(hits);
 		return ret;
@@ -1390,10 +1391,13 @@
 				p_array_init(&br->definite_uids, result->pool, 32);
 				p_array_init(&br->scores, result->pool, 32);
 			}
-			seq_range_array_add(&br->definite_uids, uid);
-			score = array_append_space(&br->scores);
-			score->uid = uid;
-			score->score = hits->score(i);
+			if (seq_range_array_add(&br->definite_uids, uid)) {
+				/* duplicate result */
+			} else {
+				score = array_append_space(&br->scores);
+				score->uid = uid;
+				score->score = hits->score(i);
+			}
 		}
 		_CLDELETE(hits);
 		return ret;


More information about the dovecot-cvs mailing list