sc/source/core/tool/dbdata.cxx |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 26d7f3440a0c9dd179ad407d48ce747699d678dd
Author:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
AuthorDate: Thu Jan 27 09:05:35 2022 +0100
Commit:     Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>
CommitDate: Thu Jan 27 11:06:18 2022 +0100

    Fix copying named DB when it doesn't contain a '_'
    
    Follow-up for d9472a5284fde7bb96823655efcb6eb31f405493
    
    Change-Id: Ib97d2c81159ddcf60604558f38e87af59cef86dd
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129023
    Tested-by: Jenkins
    Reviewed-by: Samuel Mehrbrodt <samuel.mehrbr...@allotropia.de>

diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx
index b87e388e79fc..25dc833e3732 100644
--- a/sc/source/core/tool/dbdata.cxx
+++ b/sc/source/core/tool/dbdata.cxx
@@ -998,7 +998,9 @@ OUString 
lcl_IncrementNumberInNamedRange(ScDBCollection::NamedDBs& namedDBs,
                                          const OUString& sOldName,bool 
bIsUpperName)
 {
     sal_Int32 lastIndex = sOldName.lastIndexOf('_');
-    sal_Int32 nOldNumber = OUString(sOldName.subView(lastIndex)).toInt32();
+    sal_Int32 nOldNumber = 0;
+    if (lastIndex >= 0)
+        nOldNumber = OUString(sOldName.subView(lastIndex)).toInt32();
     OUString sNewName;
     do
     {

Reply via email to