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

Stephan Bergmann sbergman at redhat.com
Tue Aug 26 09:43:54 PDT 2014


 sw/source/filter/ww8/docxattributeoutput.cxx |    8 ++++----
 sw/source/filter/ww8/rtfattributeoutput.cxx  |    6 +++---
 sw/source/filter/ww8/wrtw8nds.cxx            |    4 ++--
 sw/source/filter/ww8/wrtw8sty.cxx            |   14 +++++++-------
 sw/source/filter/ww8/wrtww8.hxx              |    4 ++--
 sw/source/filter/ww8/ww8atr.cxx              |    6 +++---
 6 files changed, 21 insertions(+), 21 deletions(-)

New commits:
commit d71aff6c47d1fc40d425a4d7fc4e718c7de5acdc
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Tue Aug 26 18:43:14 2014 +0200

    Avoid undefined null pointer dereferences
    
    ...as observed during CppunitTest_sw_rtfexport under -fsanitize=undefined
    
    Change-Id: I8f488188e233c1814a7b4bb3d21e7398d7d7c15a

diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index f6ec6e3..3e78a1a 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -2138,7 +2138,7 @@ void DocxAttributeOutput::StartRuby( const SwTxtNode& rNode, sal_Int32 nPos, con
     SwWW8AttrIter aAttrIt( m_rExport, rNode );
     aAttrIt.OutAttr( nPos, true );
 
-    sal_uInt16 nStyle = m_rExport.GetId( *rRuby.GetTxtRuby()->GetCharFmt() );
+    sal_uInt16 nStyle = m_rExport.GetId( rRuby.GetTxtRuby()->GetCharFmt() );
     OString aStyleId(m_rExport.pStyles->GetStyleId(nStyle));
     m_pSerializer->singleElementNS( XML_w, XML_rStyle,
             FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
@@ -6361,14 +6361,14 @@ void DocxAttributeOutput::TextINetFormat( const SwFmtINetFmt& rLink )
     const SwTxtINetFmt* pINetFmt = rLink.GetTxtINetFmt();
     const SwCharFmt* pCharFmt = pINetFmt->GetCharFmt();
 
-    OString aStyleId(m_rExport.pStyles->GetStyleId(m_rExport.GetId(*pCharFmt)));
+    OString aStyleId(m_rExport.pStyles->GetStyleId(m_rExport.GetId(pCharFmt)));
 
     m_pSerializer->singleElementNS( XML_w, XML_rStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
 }
 
 void DocxAttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt )
 {
-    OString aStyleId(m_rExport.pStyles->GetStyleId(m_rExport.GetId(*rCharFmt.GetCharFmt())));
+    OString aStyleId(m_rExport.pStyles->GetStyleId(m_rExport.GetId(rCharFmt.GetCharFmt())));
 
     m_pSerializer->singleElementNS( XML_w, XML_rStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
 }
@@ -6579,7 +6579,7 @@ void DocxAttributeOutput::TextFootnote_Impl( const SwFmtFtn& rFootnote )
     // footnote/endnote run properties
     const SwCharFmt* pCharFmt = rInfo.GetAnchorCharFmt( *m_rExport.pDoc );
 
-    OString aStyleId(m_rExport.pStyles->GetStyleId(m_rExport.GetId(*pCharFmt)));
+    OString aStyleId(m_rExport.pStyles->GetStyleId(m_rExport.GetId(pCharFmt)));
 
     m_pSerializer->singleElementNS( XML_w, XML_rStyle, FSNS( XML_w, XML_val ), aStyleId.getStr(), FSEND );
 
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index 6364b98..107aea3 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -2410,7 +2410,7 @@ void RtfAttributeOutput::TextINetFormat(const SwFmtINetFmt& rURL)
 
         if (pTxtAtr && 0 != (pFmt = pTxtAtr->GetCharFmt()))
         {
-            sal_uInt16 nStyle = m_rExport.GetId(*pFmt);
+            sal_uInt16 nStyle = m_rExport.GetId(pFmt);
             OString* pString = m_rExport.GetStyle(nStyle);
             if (pString)
                 m_aStyles.append(*pString);
@@ -2420,7 +2420,7 @@ void RtfAttributeOutput::TextINetFormat(const SwFmtINetFmt& rURL)
 
 void RtfAttributeOutput::TextCharFormat(const SwFmtCharFmt& rCharFmt)
 {
-    sal_uInt16 nStyle = m_rExport.GetId(*rCharFmt.GetCharFmt());
+    sal_uInt16 nStyle = m_rExport.GetId(rCharFmt.GetCharFmt());
     m_aStyles.append(OOO_STRING_SVTOOLS_RTF_CS);
     m_aStyles.append((sal_Int32)nStyle);
     OString* pString = m_rExport.GetStyle(nStyle);
@@ -2626,7 +2626,7 @@ void RtfAttributeOutput::ParaNumRule_Impl(const SwTxtNode* pTxtNd, sal_Int32 nLv
         aLR.SetTxtLeft(aLR.GetTxtLeft() + pFmt->GetIndentAt());
         aLR.SetTxtFirstLineOfst(pFmt->GetFirstLineOffset());
 
-        sal_uInt16 nStyle = m_rExport.GetId(*pFmt->GetCharFmt());
+        sal_uInt16 nStyle = m_rExport.GetId(pFmt->GetCharFmt());
         OString* pString = m_rExport.GetStyle(nStyle);
         if (pString)
             m_aStyles.append(*pString);
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 266997b..c51d4ca 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1689,7 +1689,7 @@ void WW8AttributeOutput::FormatDrop( const SwTxtNode& rNode, const SwFmtDrop &rS
             if ( pSwCharFmt )
             {
                 m_rWW8Export.InsUInt16( NS_sprm::LN_CIstd );
-                m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *pSwCharFmt ) );
+                m_rWW8Export.InsUInt16( m_rWW8Export.GetId( pSwCharFmt ) );
             }
 
             m_rWW8Export.InsUInt16( NS_sprm::LN_CHpsPos );            // Lower the chars
@@ -1704,7 +1704,7 @@ void WW8AttributeOutput::FormatDrop( const SwTxtNode& rNode, const SwFmtDrop &rS
             if ( pSwCharFmt )
             {
                 m_rWW8Export.InsUInt16( 80 );
-                m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *pSwCharFmt ) );
+                m_rWW8Export.InsUInt16( m_rWW8Export.GetId( pSwCharFmt ) );
             }
 
             m_rWW8Export.pO->push_back( 101 );      // Lower the chars
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index ea10666..ff70ccb 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -117,9 +117,9 @@ public:
 
 // GetId( SwCharFmt ) for use in text -> zero is not allowed,
 // use "Default Char Style" instead
-sal_uInt16 MSWordExportBase::GetId( const SwCharFmt& rFmt ) const
+sal_uInt16 MSWordExportBase::GetId( const SwCharFmt* pFmt ) const
 {
-    sal_uInt16 nRet = pStyles->GetSlot( rFmt );
+    sal_uInt16 nRet = pStyles->GetSlot( pFmt );
     return ( nRet != 0x0fff ) ? nRet : 10;      // Default Char Style
 }
 
@@ -127,7 +127,7 @@ sal_uInt16 MSWordExportBase::GetId( const SwCharFmt& rFmt ) const
 // "Standard" instead
 sal_uInt16 MSWordExportBase::GetId( const SwTxtFmtColl& rColl ) const
 {
-    sal_uInt16 nRet = pStyles->GetSlot( rColl );
+    sal_uInt16 nRet = pStyles->GetSlot( &rColl );
     return ( nRet != 0xfff ) ? nRet : 0;        // Default TxtFmtColl
 }
 
@@ -163,11 +163,11 @@ MSWordStyles::~MSWordStyles()
 }
 
 // Sty_SetWWSlot() dependencies for the styles -> zero is allowed
-sal_uInt16 MSWordStyles::GetSlot( const SwFmt& rFmt ) const
+sal_uInt16 MSWordStyles::GetSlot( const SwFmt* pFmt ) const
 {
     sal_uInt16 n;
     for ( n = 0; n < nUsedSlots; n++ )
-        if ( pFmtA[n] == &rFmt )
+        if ( pFmtA[n] == pFmt )
             return n;
     return 0xfff;                   // 0xfff: WW: zero
 }
@@ -541,7 +541,7 @@ void MSWordStyles::GetStyleData( SwFmt* pFmt, bool& bFmtColl, sal_uInt16& nBase,
 
     // Derived from?
     if ( !pFmt->IsDefault() )
-        nBase = GetSlot( *pFmt->DerivedFrom() );
+        nBase = GetSlot( pFmt->DerivedFrom() );
 
     SwFmt* pNext;
     if ( bFmtColl )
@@ -549,7 +549,7 @@ void MSWordStyles::GetStyleData( SwFmt* pFmt, bool& bFmtColl, sal_uInt16& nBase,
     else
         pNext = pFmt; // CharFmt: next CharFmt == self
 
-    nNext = GetSlot( *pNext );
+    nNext = GetSlot( pNext );
 }
 
 void WW8AttributeOutput::DefaultStyle( sal_uInt16 nStyle )
diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx
index d4eaa22..d2ca234 100644
--- a/sw/source/filter/ww8/wrtww8.hxx
+++ b/sw/source/filter/ww8/wrtww8.hxx
@@ -590,7 +590,7 @@ public:
     sal_uInt16 GetId( const SwTxtFmtColl& rColl ) const;
 
     /// Return the numeric id of the style.
-    sal_uInt16 GetId( const SwCharFmt& rFmt ) const;
+    sal_uInt16 GetId( const SwCharFmt* pFmt ) const;
 
     sal_uInt16 GetId( const SwTOXType& rTOXType );
 
@@ -1611,7 +1611,7 @@ public:
     void OutputStylesTable();
 
     /// Get id of the style (rFmt).
-    sal_uInt16 GetSlot( const SwFmt& rFmt ) const;
+    sal_uInt16 GetSlot( const SwFmt* pFmt ) const;
 
     /// Get styleId of the nId-th style (nId is its position in pFmtA).
     OString GetStyleId(sal_uInt16 nId) const;
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 5e8de51..82f8ea0 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -1718,7 +1718,7 @@ void WW8AttributeOutput::TextINetFormat( const SwFmtINetFmt& rINet )
         else
             m_rWW8Export.pO->push_back( 80 );
 
-        m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *pFmt ) );
+        m_rWW8Export.InsUInt16( m_rWW8Export.GetId( pFmt ) );
     }
 }
 
@@ -3281,7 +3281,7 @@ void WW8Export::WriteFtnBegin( const SwFmtFtn& rFtn, ww::bytes* pOutArr )
         SwWW8Writer::InsUInt16( aAttrArr, NS_sprm::LN_CIstd );
     else
         aAttrArr.push_back( 80 );
-    SwWW8Writer::InsUInt16( aAttrArr, GetId( *pCFmt ) );
+    SwWW8Writer::InsUInt16( aAttrArr, GetId( pCFmt ) );
 
                                                 // fSpec-Attribut true
                             // Fuer Auto-Nummer muss ein Spezial-Zeichen
@@ -3403,7 +3403,7 @@ void WW8AttributeOutput::TextCharFormat( const SwFmtCharFmt& rCharFmt )
         else
             m_rWW8Export.pO->push_back( 80 );
 
-        m_rWW8Export.InsUInt16( m_rWW8Export.GetId( *rCharFmt.GetCharFmt() ) );
+        m_rWW8Export.InsUInt16( m_rWW8Export.GetId( rCharFmt.GetCharFmt() ) );
     }
 }
 


More information about the Libreoffice-commits mailing list