sc/source/core/data/queryiter.cxx |    6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

New commits:
commit b55a0eea78837d43e77078e96729befb8e420773
Author:     Luboš Luňák <l.lu...@collabora.com>
AuthorDate: Tue Jun 28 17:52:43 2022 +0200
Commit:     Luboš Luňák <l.lu...@collabora.com>
CommitDate: Tue Jun 28 21:19:15 2022 +0200

    don't try to use self-referencing ScSortedRangeCache (tdf#149752)
    
    Both the documents from the bugreport use COUNTIF where the range
    includes the cell itself. So trying to create ScSortedRangeCache
    for the range would try to read the values of the cells in the range
    including the cell itself, which would try to interpret COUNTIF,
    which would recurse and deadlock on the mutex.
    
    Change-Id: I95c33d0b75015dcd1d628740ef52c2d680864791
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136581
    Tested-by: Jenkins
    Reviewed-by: Luboš Luňák <l.lu...@collabora.com>

diff --git a/sc/source/core/data/queryiter.cxx 
b/sc/source/core/data/queryiter.cxx
index e712b24d4443..36272b95bcbf 100644
--- a/sc/source/core/data/queryiter.cxx
+++ b/sc/source/core/data/queryiter.cxx
@@ -1259,7 +1259,9 @@ static bool CanBeUsedForSorterCache(ScDocument& rDoc, 
const ScQueryParam& rParam
         if(!inUnitTest)
             return false;
     }
-    if( !cell || !cell->GetCellGroup() || cell->GetCellGroup()->mnLength < 10 )
+    if( !cell )
+        return false;
+    if( !cell->GetCellGroup() || cell->GetCellGroup()->mnLength < 10 )
     {
         if(!inUnitTest)
             return false;
@@ -1269,6 +1271,8 @@ static bool CanBeUsedForSorterCache(ScDocument& rDoc, 
const ScQueryParam& rParam
     for(SCCOL col : rDoc.GetAllocatedColumnsRange(nTab, rParam.nCol1, 
rParam.nCol2))
     {
         ScRange aSortedRangeRange( col, rParam.nRow1, nTab, col, rParam.nRow2, 
nTab);
+        if( aSortedRangeRange.Contains( cell->aPos ))
+            return false; // self-referencing, can't create cache
         ScSortedRangeCache& cache = rDoc.GetSortedRangeCache( 
aSortedRangeRange, rParam, &context );
         if(!cache.isValid())
             return false;

Reply via email to