summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorNorbert Thiebaud <nthiebaud@gmail.com>2012-11-18 02:49:27 -0600
committerNorbert Thiebaud <nthiebaud@gmail.com>2012-11-18 02:50:14 -0600
commite3e7dfa01119b5f5ab7abc3c6e26049de5d3cc45 (patch)
tree64a4ecd10df73d61a41d840eb67e2aa41332d80e /basic
parent894675a6691de72d3ab2a6f4c5314ff842e90578 (diff)
basic: fix OUString copy overrun in Mid()
Change-Id: I91cdd3a52917b89ab2a452e0eeb7a9e00dc35e8b Reported-by: vmiklos@suse.cz
Diffstat (limited to 'basic')
-rw-r--r--basic/source/runtime/methods.cxx13
1 files changed, 12 insertions, 1 deletions
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 08d6699f9785..18da6ae72ef7 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1267,7 +1267,18 @@ RTLFUNC(Mid)
else
{
OUString aResultStr;
- aResultStr = aArgStr.copy( nStartPos, nLen );
+ if(nLen < 0)
+ {
+ aResultStr = aArgStr.copy( nStartPos);
+ }
+ else
+ {
+ if(nStartPos + nLen > aArgStr.getLength())
+ {
+ nLen = aArgStr.getLength() - nStartPos;
+ }
+ aResultStr = aArgStr.copy( nStartPos, nLen );
+ }
rPar.Get(0)->PutString( aResultStr );
}
}