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

Stephan Bergmann sbergman at redhat.com
Wed Oct 9 09:57:27 PDT 2013


 sw/source/core/unocore/unofield.cxx |    8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

New commits:
commit d703c8f64c6cd650bb753cf1f6f39b3e81f06a41
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Oct 9 18:56:40 2013 +0200

    rtl::OUString::copy needs to check for out-of-bounds
    
    ...regression introduced by 5089bdb234a93bcb62b597c18b8ab66048246b13 "Related: fdo#38838 remove UniString::EqualsAscii"
    
    Change-Id: I1d2b78122592a57fe740e36d7811d563edf1e2c4

diff --git a/sw/source/core/unocore/unofield.cxx b/sw/source/core/unocore/unofield.cxx
index 14dc73c..fff259f 100644
--- a/sw/source/core/unocore/unofield.cxx
+++ b/sw/source/core/unocore/unofield.cxx
@@ -17,6 +17,10 @@
  *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
  */
 
+#include "sal/config.h"
+
+#include <algorithm>
+
 #include <unofield.hxx>
 #include <unofieldcoll.hxx>
 #include <swtypes.hxx>
@@ -2640,7 +2644,7 @@ uno::Any SwXTextFieldMasters::getByName(const OUString& rName)
     if( USHRT_MAX == nResId )
         throw container::NoSuchElementException();
 
-    sName = sName.copy(sTypeName.getLength()+1);
+    sName = sName.copy(std::min(sTypeName.getLength()+1, sName.getLength()));
     SwFieldType* pType = GetDoc()->GetFldType(nResId, sName, sal_True);
     if(!pType)
         throw container::NoSuchElementException();
@@ -2727,7 +2731,7 @@ sal_Bool SwXTextFieldMasters::hasByName(const OUString& rName) throw( uno::Runti
     sal_Bool bRet = sal_False;
     if( USHRT_MAX != nResId )
     {
-        sName = sName.copy(sTypeName.getLength()+1);
+        sName = sName.copy(std::min(sTypeName.getLength()+1, sName.getLength()));
         bRet = USHRT_MAX != nResId && 0 != GetDoc()->GetFldType(nResId, sName, sal_True);
     }
     return bRet;


More information about the Libreoffice-commits mailing list