sc/source/ui/unoobj/cellsuno.cxx |    4 +++-
 sc/source/ui/vba/vbarange.cxx    |    9 ++++++---
 2 files changed, 9 insertions(+), 4 deletions(-)

New commits:
commit 45f2ad8f0ec4088217233132cab093180edec79c
Author:     Eike Rathke <er...@redhat.com>
AuthorDate: Tue Jun 14 13:55:09 2022 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Thu Jun 16 10:04:17 2022 +0200

    Related: tdf#149325 Fix yet another VbaRange empty ScRangeList access
    
    Change-Id: If2c44795ab794482b841138bdd55f37c4d30b592
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135824
    Reviewed-by: Eike Rathke <er...@redhat.com>
    Tested-by: Jenkins
    (cherry picked from commit 9470c5531dc928d438a6a7f4d47f2d82f2296cc1)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135874
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sc/source/ui/unoobj/cellsuno.cxx b/sc/source/ui/unoobj/cellsuno.cxx
index 622307974a75..566a989ecafc 100644
--- a/sc/source/ui/unoobj/cellsuno.cxx
+++ b/sc/source/ui/unoobj/cellsuno.cxx
@@ -6721,7 +6721,9 @@ uno::Reference<sheet::XSheetCellCursor> SAL_CALL 
ScTableSheetObj::createCursorBy
         if (pRangesImp)
         {
             const ScRangeList& rRanges = pRangesImp->GetRangeList();
-            OSL_ENSURE( rRanges.size() == 1, "Range? Ranges?" );
+            SAL_WARN_IF( rRanges.size() != 1, "sc", 
"ScTableSheetObj::createCursorByRange: Range? Ranges?");
+            if (rRanges.empty())
+                return nullptr;
             return new ScCellCursorObj( pDocSh, rRanges[ 0 ] );
         }
     }
diff --git a/sc/source/ui/vba/vbarange.cxx b/sc/source/ui/vba/vbarange.cxx
index d9a008313dc0..351cbdc60a75 100644
--- a/sc/source/ui/vba/vbarange.cxx
+++ b/sc/source/ui/vba/vbarange.cxx
@@ -1285,9 +1285,12 @@ uno::Reference< sheet::XSheetCellRange > 
lclExpandToMerged( const uno::Reference
     {
         aOldAddress = aNewAddress;
         uno::Reference< sheet::XSheetCellCursor > xCursor( 
xSheet->createCursorByRange( xNewCellRange ), uno::UNO_SET_THROW );
-        xCursor->collapseToMergedArea();
-        xNewCellRange.set( xCursor, uno::UNO_QUERY_THROW );
-        aNewAddress = lclGetRangeAddress( xNewCellRange );
+        if (xCursor.is())
+        {
+            xCursor->collapseToMergedArea();
+            xNewCellRange.set( xCursor, uno::UNO_QUERY_THROW );
+            aNewAddress = lclGetRangeAddress( xNewCellRange );
+        }
     }
     while( bRecursive && (aOldAddress != aNewAddress) );
     return xNewCellRange;

Reply via email to