sc/source/ui/vba/vbaworksheet.cxx |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

New commits:
commit b6ffe34e5ec64b20ab91dc7cd8fa9cd6b015caff
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Tue Jul 4 14:06:26 2023 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Tue Jul 4 21:08:23 2023 +0200

    sc: fix crash in ScVbaWorksheet::Cells
    
    See 
https://crashreport.libreoffice.org/stats/signature/ScDocShell::GetDocument()
    
    Similar to 286a1c03fa10acf60f076a0af987112d24cb2ff5
    "sc: check excel::getDocShell"
    
    Change-Id: I102e575b4992e175d4e780ef2b43f887d94bbd24
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153964
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit c7a8889302fd7e9e0665c3d21510e374cff3891e)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153991

diff --git a/sc/source/ui/vba/vbaworksheet.cxx 
b/sc/source/ui/vba/vbaworksheet.cxx
index 46b0e131f7e0..466e904d6f55 100644
--- a/sc/source/ui/vba/vbaworksheet.cxx
+++ b/sc/source/ui/vba/vbaworksheet.cxx
@@ -681,8 +681,9 @@ ScVbaWorksheet::Cells( const ::uno::Any &nRow, const 
::uno::Any &nCol )
     // Use a common helper method instead of creating a new ScVbaRange object
     uno::Reference< table::XCellRange > xRange( getSheet(), 
uno::UNO_QUERY_THROW );
     uno::Reference< frame::XModel > xModel( getModel(), uno::UNO_SET_THROW );
-    ScDocument& rDoc = excel::getDocShell( xModel )->GetDocument();
-    return ScVbaRange::CellsHelper( rDoc, this, mxContext, xRange, nRow, nCol 
);
+    if(ScDocShell* pShell = excel::getDocShell( xModel ))
+        return ScVbaRange::CellsHelper(pShell->GetDocument(), this, mxContext, 
xRange, nRow, nCol );
+    throw uno::RuntimeException();
 }
 
 uno::Reference< excel::XRange >

Reply via email to