summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2021-03-15 13:41:58 +0100
committerCaolán McNamara <caolanm@redhat.com>2021-03-19 09:58:23 +0100
commitd3f425c85d4664069f5b7e5d380a407631070da7 (patch)
tree288e162fbfc7f69f4cd4143c4b70d61c944d1313
parenttdf#134607 use kMDItemFSName instead of _kMDItemDisplayNameWithExtensions (diff)
downloadcore-d3f425c85d4664069f5b7e5d380a407631070da7.tar.gz
core-d3f425c85d4664069f5b7e5d380a407631070da7.zip
tdf#141045 - fixed copy paste error in the replace function
Change-Id: Id68670fed89e4cc700c5eea395139914bebdb657 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112509 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de> (cherry picked from commit ac0b6fb3842201e438950ea99a55ad334f8521ab) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112512 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org> (cherry picked from commit fde29198bd8e345c9a61a9f4d4671a3022a84cf9) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112520 Reviewed-by: Michael Stahl <michael.stahl@allotropia.de> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
-rw-r--r--basic/qa/basic_coverage/test_string_replace.vb6
-rw-r--r--basic/source/runtime/methods.cxx2
2 files changed, 7 insertions, 1 deletions
diff --git a/basic/qa/basic_coverage/test_string_replace.vb b/basic/qa/basic_coverage/test_string_replace.vb
index 99eafdba6b14..e2e9ce35962b 100644
--- a/basic/qa/basic_coverage/test_string_replace.vb
+++ b/basic/qa/basic_coverage/test_string_replace.vb
@@ -23,6 +23,12 @@ Function verify_stringReplace() As String
retStr = Replace("АБВабв", "б", "*")
TestLog_ASSERT retStr, "А*Ва*в", "case-insensitive non-ASCII: " & retStr
+ ' tdf#141045 - different length of search and replace string. It is important
+ ' that the search string starts with the original string in order to test the error.
+ ' Without the fix in place, the string index calculations result in a crash.
+ retStr = Replace("a", "abc", "ab")
+ TestLog_ASSERT retStr, "a", "different length of search and replace string: " & retStr
+
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_stringReplace = result
End Function
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 1fbcdd9680e2..1a598490d68a 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1286,7 +1286,7 @@ void SbRtl_Replace(StarBASIC *, SbxArray & rPar, bool)
const css::lang::Locale& rLocale = Application::GetSettings().GetUILanguageTag().getLocale();
css::uno::Reference < i18n::XCharacterClassification > xCharClass = vcl::unohelper::CreateCharacterClassification();
aSrcStr = xCharClass->toUpper(aSrcStr, 0, aSrcStr.getLength(), rLocale);
- aFindStr = xCharClass->toUpper(aFindStr, 0, aSrcStr.getLength(), rLocale);
+ aFindStr = xCharClass->toUpper(aFindStr, 0, aFindStr.getLength(), rLocale);
}
// Note: the result starts from lStartPos, removing everything to the left. See i#94895.