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

Stephan Bergmann sbergman at redhat.com
Wed Apr 16 11:45:04 PDT 2014


 sw/source/core/text/inftxt.cxx |   12 +++++++-----
 sw/source/core/text/inftxt.hxx |    2 +-
 sw/source/core/text/porfld.cxx |    3 +--
 sw/source/core/text/portxt.cxx |    7 +++----
 4 files changed, 12 insertions(+), 12 deletions(-)

New commits:
commit 2ecc196419c7eae4e1a286fb209cfb4b6df23550
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Wed Apr 16 20:43:37 2014 +0200

    Do not pass bad pointers to strlen
    
    ...neither a pointer to a lone char nor null
    
    Change-Id: I08a4f6b80310e23edd614490633b677bd50323a4

diff --git a/sw/source/core/text/inftxt.cxx b/sw/source/core/text/inftxt.cxx
index d1dc520..001844d 100644
--- a/sw/source/core/text/inftxt.cxx
+++ b/sw/source/core/text/inftxt.cxx
@@ -1659,7 +1659,7 @@ SwTxtSlot::SwTxtSlot(
     const SwLinePortion *pPor,
     bool bTxtLen,
     bool bExgLists,
-    const sal_Char *pCh )
+    OUString const & pCh )
     : pOldTxt(0)
     , pOldSmartTagList(0)
     , pOldGrammarCheckList(0)
@@ -1668,13 +1668,15 @@ SwTxtSlot::SwTxtSlot(
     , nLen(0)
     , pInf(NULL)
 {
-    if( pCh )
+    if( pCh.isEmpty() )
     {
-        aTxt = OUString( pCh, strlen(pCh), RTL_TEXTENCODING_MS_1252 );
-        bOn = true;
+        bOn = pPor->GetExpTxt( *pNew, aTxt );
     }
     else
-        bOn = pPor->GetExpTxt( *pNew, aTxt );
+    {
+        aTxt = pCh;
+        bOn = true;
+    }
 
     // The text is replaced ...
     if( bOn )
diff --git a/sw/source/core/text/inftxt.hxx b/sw/source/core/text/inftxt.hxx
index d81d16e..112bed8 100644
--- a/sw/source/core/text/inftxt.hxx
+++ b/sw/source/core/text/inftxt.hxx
@@ -777,7 +777,7 @@ public:
     // The replacement string originates either from the portion via GetExpText()
     // or from the char * pCh, if it is not NULL
     SwTxtSlot( const SwTxtSizeInfo *pNew, const SwLinePortion *pPor, bool bTxtLen,
-               bool bExgLists, const sal_Char *pCh = NULL );
+               bool bExgLists, OUString const & pCh = OUString() );
     ~SwTxtSlot();
     bool IsOn() const { return bOn; }
 };
diff --git a/sw/source/core/text/porfld.cxx b/sw/source/core/text/porfld.cxx
index e711579..7064e43 100644
--- a/sw/source/core/text/porfld.cxx
+++ b/sw/source/core/text/porfld.cxx
@@ -713,7 +713,6 @@ void SwNumberPortion::Paint( const SwTxtPaintInfo &rInf ) const
             if( bPaintSpace && nOldWidth > nSpaceOffs )
             {
                 SwTxtPaintInfo aInf( rInf );
-static sal_Char const sDoubleSpace[] = "  ";
                 aInf.X( aInf.X() + nSpaceOffs );
 
                 // #i53199# Adjust position of underline:
@@ -725,7 +724,7 @@ static sal_Char const sDoubleSpace[] = "  ";
 
                 pThis->Width( nOldWidth - nSpaceOffs + 12 );
                 {
-                    SwTxtSlot aDiffTxt( &aInf, this, true, false, sDoubleSpace );
+                    SwTxtSlot aDiffTxt( &aInf, this, true, false, "  " );
                     aInf.DrawText( *this, aInf.GetLen(), true );
                 }
             }
diff --git a/sw/source/core/text/portxt.cxx b/sw/source/core/text/portxt.cxx
index ebeef8e..a379e4c 100644
--- a/sw/source/core/text/portxt.cxx
+++ b/sw/source/core/text/portxt.cxx
@@ -719,7 +719,7 @@ bool SwTxtInputFldPortion::Format( SwTxtFormatInfo &rInf )
     }
     else
     {
-        SwTxtSlot aFormatTxt( &rInf, this, true, true, 0 );
+        SwTxtSlot aFormatTxt( &rInf, this, true, true );
         if ( rInf.GetLen() == 0 )
         {
             Width( 0 );
@@ -763,9 +763,8 @@ void SwTxtInputFldPortion::Paint( const SwTxtPaintInfo &rInf ) const
     if ( Width() )
     {
         rInf.DrawViewOpt( *this, POR_INPUTFLD );
-        static sal_Char sSpace = ' ';
         SwTxtSlot aPaintTxt( &rInf, this, true, true,
-                            ContainsOnlyDummyChars() ? &sSpace : 0 );
+                             ContainsOnlyDummyChars() ? OUString(" ") : OUString() );
         SwTxtPortion::Paint( rInf );
     }
 }
@@ -790,7 +789,7 @@ bool SwTxtInputFldPortion::GetExpTxt( const SwTxtSizeInfo &rInf, OUString &rTxt
 
 SwPosSize SwTxtInputFldPortion::GetTxtSize( const SwTxtSizeInfo &rInf ) const
 {
-    SwTxtSlot aFormatTxt( &rInf, this, true, false, 0 );
+    SwTxtSlot aFormatTxt( &rInf, this, true, false );
     if ( rInf.GetLen() == 0 )
     {
         return SwPosSize( 0, 0 );


More information about the Libreoffice-commits mailing list