Package: xapian-core / 1.4.3-2+deb9u3

fix-unweighted-and.patch Patch series | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
Description: Fix incorrect results due to uninitialised memory
    The array holding max weight values in MultiAndPostList is never
    initialised if the operator is unweighted, but the values are still
    used to calculate the max weight to pass to subqueries, leading to
    incorrect results.  This can be observed with an OR under an unweighted
    AND (e.g. OR under AND on the right side of AND_NOT).
    
    The fix applied is to simply default initialise this array, which
    should lead to a max weight of 0.0 being passed on to subqueries.
    
    Bug reported in notmuch by Kirill A. Shutemov, and forwarded by
    David Bremner.
Author: Olly Betts <olly@survex.com>
Bug-Debian: https://bugs.debian.org/857693
Origin: upstream
Last-Update: 2017-04-06

--- a/matcher/multiandpostlist.cc
+++ b/matcher/multiandpostlist.cc
@@ -32,7 +32,7 @@
 {
     plist = new PostList * [n_kids];
     try {
-	max_wt = new double [n_kids];
+	max_wt = new double [n_kids]();
     } catch (...) {
 	delete [] plist;
 	plist = NULL;
--- a/tests/api_query.cc
+++ b/tests/api_query.cc
@@ -658,3 +658,18 @@
 
     return true;
 }
+
+// Regression test for bug fixed in 1.4.4 and 1.2.25.
+DEFINE_TESTCASE(notandor1, backend) {
+    Xapian::Database db(get_database("etext"));
+    Xapian::Query q =
+	Xapian::Query("the") &~ (Xapian::Query("friedrich") &
+		(Xapian::Query("day") | Xapian::Query("night")));
+    Xapian::Enquire enq(db);
+    enq.set_query(q);
+
+    Xapian::MSet mset = enq.get_mset(0, 10, db.get_doccount());
+    TEST_EQUAL(mset.get_matches_estimated(), 344);
+
+    return true;
+}
--- a/tests/api_collated.h
+++ b/tests/api_collated.h
@@ -301,6 +301,7 @@
 	    { "zeroestimate1", test_zeroestimate1 },
 	    { "complexphrase3", test_complexphrase3 },
 	    { "complexnear3", test_complexnear3 },
+	    { "notandor1", test_notandor1 },
 	    { "wildquery1", test_wildquery1 },
 	    { "snippet1", test_snippet1 },
 	    { "snippetstem1", test_snippetstem1 },
--- a/tests/api_query.h
+++ b/tests/api_query.h
@@ -21,3 +21,4 @@
 extern bool test_complexphrase3();
 extern bool test_complexnear3();
 extern bool test_subdbwithoutpos1();
+extern bool test_notandor1();