[Libreoffice-commits] core.git: basic/source

Julien Nabet serval2412 at yahoo.fr
Fri Jan 23 12:33:24 PST 2015


 basic/source/runtime/methods.cxx |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

New commits:
commit b7d02d7a5a374da3e01e0abc4022fba35daa1840
Author: Julien Nabet <serval2412 at yahoo.fr>
Date:   Tue Dec 30 21:48:21 2014 +0100

    Resolves fdo#87834: strange behavior of mid()-function
    
    See https://bugs.freedesktop.org/show_bug.cgi?id=87834
    Thank you Michael Büssow for pointing these cases
    
    Change-Id: I3a9b58360ddab529d1fb2f7eeba7f1c7ae69ba7c
    Reviewed-on: https://gerrit.libreoffice.org/13707
    Reviewed-by: Caolán McNamara <caolanm at redhat.com>
    Tested-by: Caolán McNamara <caolanm at redhat.com>

diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 2817815..d3928a5 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;


More information about the Libreoffice-commits mailing list