sc/source/core/tool/dbdata.cxx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
New commits: commit 36003e7644014cde9330bf45fee3815278a74035 Author: Noel Grandin <noel.gran...@collabora.co.uk> AuthorDate: Wed Sep 28 11:19:25 2022 +0200 Commit: Noel Grandin <noel.gran...@collabora.co.uk> CommitDate: Wed Sep 28 13:57:39 2022 +0200 fix bug in lcl_IncrementNumberInNamedRange from commit 690e4852809ea21b5fd909298c5fa2a053fa0458 Date: Mon Jan 31 09:02:33 2022 +0100 Fix copying range when it doesn't contain a number OUString::lastIndexOf() eithers returns an index or -1, so adding 1 to it, means that nLastIndex is __always__ >= 0. Change-Id: I197f8c856a52534690d7a0d28e49cecf296dccb3 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140704 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> diff --git a/sc/source/core/tool/dbdata.cxx b/sc/source/core/tool/dbdata.cxx index 5a2fa75684de..0b54c6504371 100644 --- a/sc/source/core/tool/dbdata.cxx +++ b/sc/source/core/tool/dbdata.cxx @@ -1009,10 +1009,11 @@ public: OUString lcl_IncrementNumberInNamedRange(ScDBCollection::NamedDBs& namedDBs, const OUString& sOldName) { - sal_Int32 nLastIndex = sOldName.lastIndexOf('_') + 1; + sal_Int32 nLastIndex = sOldName.lastIndexOf('_'); sal_Int32 nOldNumber = 1; if (nLastIndex >= 0) { + ++nLastIndex; std::u16string_view sLastPart(sOldName.subView(nLastIndex)); nOldNumber = o3tl::toInt32(sLastPart);