summaryrefslogtreecommitdiff
path: root/basic/source/runtime/methods.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'basic/source/runtime/methods.cxx')
-rw-r--r--basic/source/runtime/methods.cxx10
1 files changed, 8 insertions, 2 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 281781550d32..d3928a599662 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1205,7 +1205,7 @@ RTLFUNC(Mid)
}
OUString aArgStr = rPar.Get(1)->GetOUString();
sal_Int32 nStartPos = rPar.Get(2)->GetLong();
- if ( nStartPos == 0 )
+ if ( nStartPos < 1 )
{
StarBASIC::Error( SbERR_BAD_ARGUMENT );
}
@@ -1279,12 +1279,18 @@ RTLFUNC(Mid)
else
{
OUString aResultStr;
- if(nLen < 0)
+ if (nStartPos > aArgStr.getLength())
+ {
+ aResultStr = "";
+ }
+ else if(nArgCount == 2)
{
aResultStr = aArgStr.copy( nStartPos);
}
else
{
+ if (nLen < 0)
+ nLen = 0;
if(nStartPos + nLen > aArgStr.getLength())
{
nLen = aArgStr.getLength() - nStartPos;