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

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


details:   http://hg.dovecot.org/dovecot-2.1/rev/79bae66e666c
changeset: 15012:79bae66e666c
user:      Timo Sirainen <tss at iki.fi>
date:      Tue Mar 11 13:24:09 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 8e6b8d53c02b -r 79bae66e666c src/plugins/fts-lucene/lucene-wrapper.cc
--- a/src/plugins/fts-lucene/lucene-wrapper.cc	Wed Feb 05 00:47:55 2014 +0200
+++ b/src/plugins/fts-lucene/lucene-wrapper.cc	Tue Mar 11 13:24:09 2014 +0200
@@ -1240,7 +1240,9 @@
 				break;
 			}
 
-			if (result != NULL) {
+			if (seq_range_array_add(uids_r, 0, uid)) {
+				/* duplicate result */
+			} else if (result != NULL) {
 				if (uid < last_uid)
 					result->scores_sorted = false;
 				last_uid = uid;
@@ -1249,7 +1251,6 @@
 				score->uid = uid;
 				score->score = hits->score(i);
 			}
-			seq_range_array_add(uids_r, 0, uid);
 		}
 		_CLDELETE(hits);
 		return ret;
@@ -1358,10 +1359,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, 0, uid);
-			score = array_append_space(&br->scores);
-			score->uid = uid;
-			score->score = hits->score(i);
+			if (seq_range_array_add(&br->definite_uids, 0, 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