Query ctor must clone non-ref-counted PostingSource
commit1ca2b8b5a9de3c1b5770b7bd64b99e58df0cce03
authorOlly Betts <olly@survex.com>
Fri, 14 Oct 2016 02:15:20 +0000 (14 15:15 +1300)
committerOlly Betts <olly@survex.com>
Fri, 14 Oct 2016 21:08:50 +0000 (15 10:08 +1300)
tree3a23cedd66f18081d8c31e782065be844466e788
parent94a72cba91568f3918e9c25f4c467c2a671a8069
Query ctor must clone non-ref-counted PostingSource

In 1.2.x, we always attempted to clone the PostingSource object.  This
clone code was removed as part of the changes in 1.3.5 to support
optional reference counting of PostingSource objects, but that breaks
the case when the PostingSource object is on the stack and goes out of
scope before the Query object is used.

To fix this, we now check if the PostingSource object is reference
counted and if not then attempt to clone it as happened in 1.3.4 and
earlier.

Issue reported by Till Schäfer and analysed by Daniel Vrátil in a
bug report against Akonadi: https://bugs.kde.org/show_bug.cgi?id=363741

(cherry picked from commit cef6873ab3849875bf4c5d0147a4a07ba562bad9)
xapian-core/api/queryinternal.cc
xapian-core/tests/api_postingsource.cc