summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorNoel Power <noel.power@suse.com>2013-03-19 15:59:21 +0000
committerPetr Mladek <pmladek@suse.cz>2013-04-16 12:45:53 +0000
commitdf4b1b9be4f818ef912bfb58b514bab1acdd6e71 (patch)
treef7cd2c68a29f5d64a60b9dce57dc0b769ada5c58 /basic
parent69371d3fae481adb2b21701952570f829fcd8311 (diff)
follow on fix for fdo#62090 ensure out of range startpos is handled
Change-Id: Ic1f57480a36415998748faeea3b606a47d277181 (cherry picked from commit 0054b438013ef412c2df3b7ebe93dd1935ec07af) Reviewed-on: https://gerrit.libreoffice.org/3409 Reviewed-by: Petr Mladek <pmladek@suse.cz> Tested-by: Petr Mladek <pmladek@suse.cz>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/methods.cxx8
1 files changed, 6 insertions, 2 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 7f724b1b6810..666dbbad012d 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1261,8 +1261,12 @@ RTLFUNC(Mid)
else
{
aResultStr = aArgStr;
- aResultStr.remove( nStartPos, nLen );
- aResultStr.insert( nStartPos, rPar.Get(4)->GetOUString().getStr(), std::min(nLen, rPar.Get(4)->GetOUString().getLength()));
+ sal_Int32 nTmpStartPos = nStartPos;
+ if ( nTmpStartPos > aArgStr.getLength() )
+ nTmpStartPos = aArgStr.getLength();
+ else
+ aResultStr.remove( nTmpStartPos, nLen );
+ aResultStr.insert( nTmpStartPos, rPar.Get(4)->GetOUString().getStr(), std::min(nLen, rPar.Get(4)->GetOUString().getLength()));
}
rPar.Get(1)->PutString( aResultStr.makeStringAndClear() );