[Libreoffice-commits] core.git: sc/source

Thorsten Behrens (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 8 10:53:28 UTC 2020


 sc/source/core/data/table3.cxx      |    4 ++--
 sc/source/filter/excel/excrecds.cxx |    4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)

New commits:
commit 42f2c438976ef95c23868af3a997dd971aece7a5
Author:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
AuthorDate: Sun Sep 6 17:07:47 2020 +0200
Commit:     Thorsten Behrens <Thorsten.Behrens at CIB.de>
CommitDate: Tue Sep 8 12:52:48 2020 +0200

    Check range before accessing Calc sort userlist
    
    Change-Id: Ib5078dc4ce3f85be9b42320b60ef6fc40b684cb7
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102140
    Tested-by: Jenkins
    Tested-by: Serge Krot <Serge.Krot at cib.de>
    Reviewed-by: Thorsten Behrens <Thorsten.Behrens at CIB.de>

diff --git a/sc/source/core/data/table3.cxx b/sc/source/core/data/table3.cxx
index 449a4a900a7e..0308ee3db818 100644
--- a/sc/source/core/data/table3.cxx
+++ b/sc/source/core/data/table3.cxx
@@ -1492,9 +1492,9 @@ short ScTable::CompareCell(
                 bool bNaturalSort = aSortParam.bNaturalSort;    // natural sort
                 bool bCaseSens    = aSortParam.bCaseSens;       // case sensitivity
 
-                if (bUserDef)
+                ScUserList* pList = ScGlobal::GetUserList();
+                if (bUserDef && pList && pList->size() > aSortParam.nUserIndex )
                 {
-                    ScUserList* pList = ScGlobal::GetUserList();
                     const ScUserListData& rData = (*pList)[aSortParam.nUserIndex];
 
                     if ( bNaturalSort )
diff --git a/sc/source/filter/excel/excrecds.cxx b/sc/source/filter/excel/excrecds.cxx
index 40a74528af90..421c0e8f788b 100644
--- a/sc/source/filter/excel/excrecds.cxx
+++ b/sc/source/filter/excel/excrecds.cxx
@@ -951,7 +951,8 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const
             ScSortParam aSortParam;
             pData->GetSortParam( aSortParam );
 
-            if (aSortParam.bUserDef)
+            ScUserList* pList = ScGlobal::GetUserList();
+            if (aSortParam.bUserDef && pList && pList->size() > aSortParam.nUserIndex)
             {
                 // get sorted area without headers
                 maSortRef = ScRange(
@@ -959,7 +960,6 @@ ExcAutoFilterRecs::ExcAutoFilterRecs( const XclExpRoot& rRoot, SCTAB nTab, const
                     aParam.nCol2, aParam.nRow2, aParam.nTab );
 
                 // get sorted columns with custom lists
-                ScUserList* pList = ScGlobal::GetUserList();
                 const ScUserListData& rData = (*pList)[aSortParam.nUserIndex];
 
                 // get column index and sorting direction


More information about the Libreoffice-commits mailing list