sc/source/core/data/documen2.cxx |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

New commits:
commit 0e4b219337fc4df1ae58f3f257ea3990b615f983
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Wed May 3 19:10:31 2023 +0200
Commit:     Michael Stahl <michael.st...@allotropia.de>
CommitDate: Fri May 5 10:49:42 2023 +0200

    tdf#155037: check source code name exists
    
    Otherwise, it crashes with
    terminate called after throwing an instance of 
'com::sun::star::container::NoSuchElementException'
    
    Change-Id: Ic53bedcc19690d43aef20d4193e840e340e349d9
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151336
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caol...@redhat.com>
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>
    (cherry picked from commit 5f914d5f4b48a092736650db1e1e431787e50096)
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151371
    Reviewed-by: Michael Stahl <michael.st...@allotropia.de>

diff --git a/sc/source/core/data/documen2.cxx b/sc/source/core/data/documen2.cxx
index a7ea162177a9..2faa9cd1c7d0 100644
--- a/sc/source/core/data/documen2.cxx
+++ b/sc/source/core/data/documen2.cxx
@@ -1117,7 +1117,8 @@ sal_uLong ScDocument::TransferTab( ScDocument& rSrcDoc, 
SCTAB nSrcPos,
                 OUString sSrcCodeName;
                 rSrcDoc.GetCodeName( nSrcPos, sSrcCodeName );
                 OUString sRTLSource;
-                xLib->getByName( sSrcCodeName ) >>= sRTLSource;
+                if (xLib->hasByName( sSrcCodeName ))
+                    xLib->getByName( sSrcCodeName ) >>= sRTLSource;
                 sSource = sRTLSource;
             }
             VBA_InsertModule( *this, nDestPos, sSource );

Reply via email to