[Libreoffice-commits] core.git: editeng/source include/svl sc/source sd/source svx/source sw/source

Stephan Bergmann sbergman at redhat.com
Sat Apr 7 21:03:39 UTC 2018


 editeng/source/editeng/editdoc.cxx                |    2 +-
 include/svl/style.hxx                             |    2 +-
 sc/source/core/data/stlsheet.cxx                  |   10 +++++-----
 sc/source/filter/xml/xmlfonte.cxx                 |    2 +-
 sd/source/core/stlfamily.cxx                      |    2 +-
 sd/source/core/stlsheet.cxx                       |   16 ++++++++--------
 sd/source/filter/xml/sdtransform.cxx              |    4 ++--
 svx/source/sdr/properties/attributeproperties.cxx |    8 +++++---
 svx/source/svdraw/svdxcgv.cxx                     |    2 +-
 sw/source/core/unocore/unostyle.cxx               |    2 +-
 sw/source/uibase/app/docstyle.cxx                 |    4 ++--
 11 files changed, 28 insertions(+), 26 deletions(-)

New commits:
commit ddcc2ae791b3e5dcb80fa9eebc59879d927646b0
Author: Stephan Bergmann <sbergman at redhat.com>
Date:   Sat Apr 7 16:28:08 2018 +0200

    Avoid -fsanitize=null
    
    ...during CppunitTest_sd_filters_test (see below), where
    SfxStyleSheetBase::m_pPool has apparently been null'ed in
    SdStyleSheet::disposing (sd/source/core/stlsheet.cxx).  Presumably introduced
    with dfefe448c41921f2f1e54d3f69b8b9e89031d055 "SOSAW080: Added first bunch of
    basic changes to helpers"; adding a "TTTT" marker on alg_'s request.
    
    Needed to change SfxStyleSheetBase::GetPool to return pointer instead of ref.
    
    > include/svl/style.hxx:142:47: runtime error: reference binding to null pointer of type 'SfxStyleSheetBasePool'
    >  #0 in SfxStyleSheetBase::GetPool() at include/svl/style.hxx:142:40 (instdir/program/libsvxcorelo.so +0x2d7a3ed)
    >  #1 in sdr::properties::AttributeProperties::ImpRemoveStyleSheet() at svx/source/sdr/properties/attributeproperties.cxx:136:44 (instdir/program/libsvxcorelo.so +0x2d72f40)
    >  #2 in sdr::properties::AttributeProperties::Notify(SfxBroadcaster&, SfxHint const&) at svx/source/sdr/properties/attributeproperties.cxx:474:25 (instdir/program/libsvxcorelo.so +0x2d793ec)
    >  #3 in sdr::properties::TextProperties::Notify(SfxBroadcaster&, SfxHint const&) at svx/source/sdr/properties/textproperties.cxx:542:34 (instdir/program/libsvxcorelo.so +0x2d631f2)
    >  #4 in SfxBroadcaster::Broadcast(SfxHint const&) at svl/source/notify/SfxBroadcaster.cxx:49:24 (instdir/program/libsvllo.so +0xc2d628)
    >  #5 in (anonymous namespace)::StyleSheetDisposerFunctor::Dispose(rtl::Reference<SfxStyleSheetBase>) at svl/source/items/style.cxx:804:16 (instdir/program/libsvllo.so +0x99e4ef)
    >  #6 in svl::IndexedStyleSheets::Clear(svl::StyleSheetDisposer&) at svl/source/items/IndexedStyleSheets.cxx:202:18 (instdir/program/libsvllo.so +0x8bb852)
    >  #7 in SfxStyleSheetBasePool::Clear() at svl/source/items/style.cxx:815:34 (instdir/program/libsvllo.so +0x9965ea)
    >  #8 in SdStyleSheetPool::dispose() at sd/source/core/stlpool.cxx:1386:9 (instdir/program/libsdlo.so +0x25353a7)
    >  #9 in SdrModel::~SdrModel() at svx/source/svdraw/svdmodel.cxx:275:25 (instdir/program/libsvxcorelo.so +0x323f1ad)
    >  #10 in FmFormModel::~FmFormModel() at svx/source/form/fmmodel.cxx:94:1 (instdir/program/libsvxcorelo.so +0x465f020)
    >  #11 in SdDrawDocument::~SdDrawDocument() at sd/source/core/drawdoc.cxx:394:1 (instdir/program/libsdlo.so +0x2324254)
    >  #12 in SdDrawDocument::~SdDrawDocument() at sd/source/core/drawdoc.cxx:346:1 (instdir/program/libsdlo.so +0x2324445)
    >  #13 in SdDrawDocument::~SdDrawDocument() at sd/source/core/drawdoc.cxx:346:1 (instdir/program/libsdlo.so +0x23244ce)
    >  #14 in sd::DrawDocShell::~DrawDocShell() at sd/source/ui/docshell/docshell.cxx:200:9 (instdir/program/libsdlo.so +0x2c4bdb9)
    >  #15 in sd::DrawDocShell::~DrawDocShell() at sd/source/ui/docshell/docshell.cxx:179:1 (instdir/program/libsdlo.so +0x2c4c4a5)
    >  #16 in sd::DrawDocShell::~DrawDocShell() at sd/source/ui/docshell/docshell.cxx:179:1 (instdir/program/libsdlo.so +0x2c4c56e)
    >  #17 in SvRefBase::ReleaseRef() at include/tools/ref.hxx:165:29 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x1ff01)
    >  #18 in tools::SvRef<sd::DrawDocShell>::~SvRef() at include/tools/ref.hxx:56:36 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x1a9fc)
    >  #19 in SdFiltersTest::load(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int) at sd/qa/unit/filters-test.cxx:78:1 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x17f53)
    >  #20 in test::FiltersTest::recursiveScan(test::filterStatus, rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:130:20 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x5589c)
    >  #21 in test::FiltersTest::testDir(rtl::OUString const&, rtl::OUString const&, rtl::OUString const&, SfxFilterFlags, SotClipboardFormatId, unsigned int, bool) at unotest/source/cpp/filters-test.cxx:155:5 (workdir/LinkTarget/CppunitTest/../Library/libunotest.so +0x56519)
    >  #22 in SdFiltersTest::testCVEs() at sd/qa/unit/filters-test.cxx:83:5 (workdir/LinkTarget/CppunitTest/libtest_sd_filters_test.so +0x1839d)
    
    Change-Id: Ibf61c18738c7a204ebf2bbc85b28930481b22612
    Reviewed-on: https://gerrit.libreoffice.org/52554
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/editeng/source/editeng/editdoc.cxx b/editeng/source/editeng/editdoc.cxx
index fd22c598f1b9..97656d378576 100644
--- a/editeng/source/editeng/editdoc.cxx
+++ b/editeng/source/editeng/editdoc.cxx
@@ -2278,7 +2278,7 @@ EditPaM EditDoc::InsertParaBreak( EditPaM aPaM, bool bKeepEndingAttribs )
         OUString aFollow( pStyle->GetFollow() );
         if ( !aFollow.isEmpty() && ( aFollow != pStyle->GetName() ) )
         {
-            SfxStyleSheetBase* pNext = pStyle->GetPool().Find( aFollow, pStyle->GetFamily() );
+            SfxStyleSheetBase* pNext = pStyle->GetPool()->Find( aFollow, pStyle->GetFamily() );
             pNode->SetStyleSheet( static_cast<SfxStyleSheet*>(pNext) );
         }
     }
diff --git a/include/svl/style.hxx b/include/svl/style.hxx
index b30ddfe82ab1..40e673463386 100644
--- a/include/svl/style.hxx
+++ b/include/svl/style.hxx
@@ -139,7 +139,7 @@ public:
     virtual bool IsUsed() const;                // Default true
     virtual OUString GetDescription( MapUnit eMetric );
 
-    SfxStyleSheetBasePool& GetPool() { return *m_pPool; }
+    SfxStyleSheetBasePool* GetPool() { return m_pPool; }
     SfxStyleFamily GetFamily() const     { return nFamily; }
     sal_uInt16   GetMask() const     { return nMask; }
     void     SetMask( sal_uInt16 mask) { nMask = mask; }
diff --git a/sc/source/core/data/stlsheet.cxx b/sc/source/core/data/stlsheet.cxx
index 596a703b5c5f..f57939773372 100644
--- a/sc/source/core/data/stlsheet.cxx
+++ b/sc/source/core/data/stlsheet.cxx
@@ -113,7 +113,7 @@ bool ScStyleSheet::SetParent( const OUString& rParentName )
             // #i113491# Drag&Drop in the stylist's hierarchical view doesn't execute a slot,
             // so the repaint has to come from here (after modifying the ItemSet).
             // RepaintRange checks the document's IsVisible flag and locked repaints.
-            ScDocument* pDoc = static_cast<ScStyleSheetPool&>(GetPool()).GetDocument();
+            ScDocument* pDoc = static_cast<ScStyleSheetPool*>(GetPool())->GetDocument();
             if (pDoc)
                 pDoc->RepaintRange( ScRange( 0,0,0, MAXCOL,MAXROW,MAXTAB ) );
         }
@@ -139,7 +139,7 @@ SfxItemSet& ScStyleSheet::GetItemSet()
                     // therefore suitable values are set at this point.
                     // (== Standard page template)
 
-                    SfxItemPool& rItemPool = GetPool().GetPool();
+                    SfxItemPool& rItemPool = GetPool()->GetPool();
                     pSet = new SfxItemSet(
                         rItemPool,
                         svl::Items<
@@ -154,7 +154,7 @@ SfxItemSet& ScStyleSheet::GetItemSet()
                     //  GetPrinter would then also create a new printer,
                     //  because the stored Printer is not loaded yet!
 
-                    ScDocument* pDoc = static_cast<ScStyleSheetPool&>(GetPool()).GetDocument();
+                    ScDocument* pDoc = static_cast<ScStyleSheetPool*>(GetPool())->GetDocument();
                     if ( pDoc )
                     {
                         // Setting reasonable default values:
@@ -224,7 +224,7 @@ SfxItemSet& ScStyleSheet::GetItemSet()
 
             case SfxStyleFamily::Para:
             default:
-                pSet = new SfxItemSet( GetPool().GetPool(), svl::Items<ATTR_PATTERN_START, ATTR_PATTERN_END>{} );
+                pSet = new SfxItemSet( GetPool()->GetPool(), svl::Items<ATTR_PATTERN_START, ATTR_PATTERN_END>{} );
                 break;
         }
         bMySet = true;
@@ -237,7 +237,7 @@ SfxItemSet& ScStyleSheet::GetItemSet()
             // ~ScStyleSheetPool -> ~SfxStyleSheetPool, GetPool() is no longer
             // an ScStyleSheetPool:
             ScStyleSheetPool * pool = dynamic_cast<ScStyleSheetPool *>(
-                &GetPool());
+                GetPool());
             if (pool != nullptr) {
                 ScDocument* pDoc = pool->GetDocument();
                 if ( pDoc )
diff --git a/sc/source/filter/xml/xmlfonte.cxx b/sc/source/filter/xml/xmlfonte.cxx
index 1aa7ec0bd385..dff130e33925 100644
--- a/sc/source/filter/xml/xmlfonte.cxx
+++ b/sc/source/filter/xml/xmlfonte.cxx
@@ -101,7 +101,7 @@ ScXMLFontAutoStylePool_Impl::ScXMLFontAutoStylePool_Impl(ScXMLExport& rExportP,
 
             while (pStyle)
             {
-                const SfxItemPool& rPagePool(pStyle->GetPool().GetPool());
+                const SfxItemPool& rPagePool(pStyle->GetPool()->GetPool());
 
                 for (sal_uInt16 nPageWhichId : aPageWhichIds)
                 {
diff --git a/sd/source/core/stlfamily.cxx b/sd/source/core/stlfamily.cxx
index 7c995c4cbe37..413699e3a533 100644
--- a/sd/source/core/stlfamily.cxx
+++ b/sd/source/core/stlfamily.cxx
@@ -122,7 +122,7 @@ SdStyleSheet* SdStyleFamily::GetValidNewSheet( const Any& rElement )
     Reference< XStyle > xStyle( rElement, UNO_QUERY );
     SdStyleSheet* pStyle = static_cast< SdStyleSheet* >( xStyle.get() );
 
-    if( pStyle == nullptr || (pStyle->GetFamily() != mnFamily) || (&pStyle->GetPool() != mxPool.get()) || (mxPool->Find( pStyle->GetName(), mnFamily) != nullptr) )
+    if( pStyle == nullptr || (pStyle->GetFamily() != mnFamily) || (pStyle->GetPool() != mxPool.get()) || (mxPool->Find( pStyle->GetName(), mnFamily) != nullptr) )
         throw IllegalArgumentException();
 
     return pStyle;
diff --git a/sd/source/core/stlsheet.cxx b/sd/source/core/stlsheet.cxx
index 7b5ef91a07fc..012546b6b7e2 100644
--- a/sd/source/core/stlsheet.cxx
+++ b/sd/source/core/stlsheet.cxx
@@ -214,7 +214,7 @@ SfxItemSet& SdStyleSheet::GetItemSet()
         if (!pSet)
         {
             pSet = new SfxItemSet(
-                GetPool().GetPool(),
+                GetPool()->GetPool(),
                 svl::Items<
                     XATTR_LINE_FIRST, XATTR_LINE_LAST,
                     XATTR_FILL_FIRST, XATTR_FILL_LAST,
@@ -234,7 +234,7 @@ SfxItemSet& SdStyleSheet::GetItemSet()
         if (!pSet)
         {
             pSet = new SfxItemSet(
-                GetPool().GetPool(),
+                GetPool()->GetPool(),
                 svl::Items<
                     XATTR_LINE_FIRST, XATTR_LINE_LAST,
                     XATTR_FILL_FIRST, XATTR_FILL_LAST,
@@ -265,7 +265,7 @@ SfxItemSet& SdStyleSheet::GetItemSet()
             if (!pSet)
             {
                 pSet = new SfxItemSet(
-                    GetPool().GetPool(),
+                    GetPool()->GetPool(),
                     svl::Items<
                         XATTR_LINE_FIRST, XATTR_LINE_LAST,
                         XATTR_FILL_FIRST, XATTR_FILL_LAST,
@@ -974,7 +974,7 @@ void SAL_CALL SdStyleSheet::setPropertyValue( const OUString& aPropertyName, con
         throw IllegalArgumentException();
     }
 
-    SfxItemSet aSet( GetPool().GetPool(),   {{pEntry->nWID, pEntry->nWID}});
+    SfxItemSet aSet( GetPool()->GetPool(),   {{pEntry->nWID, pEntry->nWID}});
     aSet.Put( rStyleSet );
 
     if( !aSet.Count() )
@@ -987,7 +987,7 @@ void SAL_CALL SdStyleSheet::setPropertyValue( const OUString& aPropertyName, con
         }
         else
         {
-            aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) );
+            aSet.Put( GetPool()->GetPool().GetDefaultItem( pEntry->nWID ) );
         }
     }
 
@@ -1080,7 +1080,7 @@ Any SAL_CALL SdStyleSheet::getPropertyValue( const OUString& PropertyName )
     }
     else
     {
-        SfxItemSet aSet( GetPool().GetPool(),   {{pEntry->nWID, pEntry->nWID}});
+        SfxItemSet aSet( GetPool()->GetPool(),   {{pEntry->nWID, pEntry->nWID}});
 
         const SfxPoolItem* pItem;
         SfxItemSet& rStyleSet = GetItemSet();
@@ -1089,7 +1089,7 @@ Any SAL_CALL SdStyleSheet::getPropertyValue( const OUString& PropertyName )
             aSet.Put(  *pItem );
 
         if( !aSet.Count() )
-            aSet.Put( GetPool().GetPool().GetDefaultItem( pEntry->nWID ) );
+            aSet.Put( GetPool()->GetPool().GetDefaultItem( pEntry->nWID ) );
 
         if(SvxUnoTextRangeBase::GetPropertyValueHelper( aSet, pEntry, aAny ))
             return aAny;
@@ -1267,7 +1267,7 @@ Any SAL_CALL SdStyleSheet::getPropertyDefault( const OUString& aPropertyName )
     }
     else
     {
-        SfxItemPool& rMyPool = GetPool().GetPool();
+        SfxItemPool& rMyPool = GetPool()->GetPool();
         SfxItemSet aSet( rMyPool,   {{pEntry->nWID, pEntry->nWID}});
         aSet.Put( rMyPool.GetDefaultItem( pEntry->nWID ) );
         aRet = SvxItemPropertySet_getPropertyValue( pEntry, aSet );
diff --git a/sd/source/filter/xml/sdtransform.cxx b/sd/source/filter/xml/sdtransform.cxx
index e7d1ca8cc7a1..f496e353be0e 100644
--- a/sd/source/filter/xml/sdtransform.cxx
+++ b/sd/source/filter/xml/sdtransform.cxx
@@ -146,7 +146,7 @@ void SdTransformOOo2xDocument::transformStyle( SfxStyleSheetBase& rSheet )
     SfxItemSet& rSet = rSheet.GetItemSet();
 
     bool bState = false;
-    getBulletState( rSheet.GetItemSet(), rSheet.GetPool().Find( rSheet.GetParent(), rSheet.GetFamily() ), bState );
+    getBulletState( rSheet.GetItemSet(), rSheet.GetPool()->Find( rSheet.GetParent(), rSheet.GetFamily() ), bState );
 
     transformItemSet( rSet, bState );
     removeAlienAttributes( rSet );
@@ -266,7 +266,7 @@ bool SdTransformOOo2xDocument::getBulletState( const SfxItemSet& rSet, SfxStyleS
     if( getBulletState( rSet, SDRATTR_XMLATTRIBUTES, rState ) )
         return true;
 
-    if( pSheet && getBulletState( pSheet->GetItemSet(), pSheet->GetPool().Find( pSheet->GetParent(), pSheet->GetFamily() ), rState ) )
+    if( pSheet && getBulletState( pSheet->GetItemSet(), pSheet->GetPool()->Find( pSheet->GetParent(), pSheet->GetFamily() ), rState ) )
         return true;
 
     return false;
diff --git a/svx/source/sdr/properties/attributeproperties.cxx b/svx/source/sdr/properties/attributeproperties.cxx
index d14b7ffd6b2f..a30b818fd706 100644
--- a/svx/source/sdr/properties/attributeproperties.cxx
+++ b/svx/source/sdr/properties/attributeproperties.cxx
@@ -115,7 +115,7 @@ namespace sdr
                 if(HasSfxItemSet())
                 {
                     // register as listener
-                    StartListening(pNewStyleSheet->GetPool());
+                    StartListening(*pNewStyleSheet->GetPool());
                     StartListening(*pNewStyleSheet);
 
                     // only apply the following when we have an SfxItemSet already, else
@@ -133,7 +133,9 @@ namespace sdr
             if(GetStyleSheet() && dynamic_cast<const SfxStyleSheet *>(mpStyleSheet) != nullptr)
             {
                 EndListening(*mpStyleSheet);
-                EndListening(mpStyleSheet->GetPool());
+                if (auto const pool = mpStyleSheet->GetPool()) { // TTTT
+                    EndListening(*pool);
+                }
 
                 // reset parent of ItemSet
                 if(HasSfxItemSet())
@@ -391,7 +393,7 @@ namespace sdr
 
             // prepare forgetting the current stylesheet like in RemoveStyleSheet()
             EndListening(*mpStyleSheet);
-            EndListening(mpStyleSheet->GetPool());
+            EndListening(*mpStyleSheet->GetPool());
 
             // prepare the iter; use the mpObjectItemSet which may have less
             // WhichIDs than the style.
diff --git a/svx/source/svdraw/svdxcgv.cxx b/svx/source/svdraw/svdxcgv.cxx
index 58fc73351181..d6a807414286 100644
--- a/svx/source/svdraw/svdxcgv.cxx
+++ b/svx/source/svdraw/svdxcgv.cxx
@@ -220,7 +220,7 @@ bool SdrExchangeView::Paste(SvStream& rInput, EETextFormat eFormat, const Point&
 
             if(pCandidate)
             {
-                if(pObj->getSdrModelFromSdrObject().GetStyleSheetPool() == &pCandidate->GetPool())
+                if(pObj->getSdrModelFromSdrObject().GetStyleSheetPool() == pCandidate->GetPool())
                 {
                     pObj->NbcSetStyleSheet(pCandidate, true);
                 }
diff --git a/sw/source/core/unocore/unostyle.cxx b/sw/source/core/unocore/unostyle.cxx
index dcbdf4a79d76..b7f60b5dcc7f 100644
--- a/sw/source/core/unocore/unostyle.cxx
+++ b/sw/source/core/unocore/unostyle.cxx
@@ -947,7 +947,7 @@ void XStyleFamily::insertByName(const OUString& rName, const uno::Any& rElement)
             m_pBasePool->SetSearchMask(m_rEntry.m_eFamily);
             SfxStyleSheetBase* pParentBase = m_pBasePool->Find(sParentStyleName);
             if(pParentBase && pParentBase->GetFamily() == m_rEntry.m_eFamily &&
-                &pParentBase->GetPool() == m_pBasePool)
+                pParentBase->GetPool() == m_pBasePool)
                 m_pBasePool->SetParent(m_rEntry.m_eFamily, sStyleName, sParentStyleName);
         }
         // after all, we still need to apply the properties of the descriptor
diff --git a/sw/source/uibase/app/docstyle.cxx b/sw/source/uibase/app/docstyle.cxx
index fc55b14ecfdb..f3e46b3f2ca0 100644
--- a/sw/source/uibase/app/docstyle.cxx
+++ b/sw/source/uibase/app/docstyle.cxx
@@ -464,7 +464,7 @@ SwDocStyleSheet::SwDocStyleSheet(   SwDoc&                rDocument,
     pBoxFormat(nullptr),
     rDoc(rDocument),
     aCoreSet(
-        GetPool().GetPool(),
+        GetPool()->GetPool(),
         svl::Items<
             RES_CHRATR_BEGIN, RES_CHRATR_END - 1,
             RES_PARATR_BEGIN, RES_FRMATR_END - 1,
@@ -2651,7 +2651,7 @@ SwStyleSheetIterator::SwStyleSheetIterator( SwDocStyleSheetPool* pBase,
 
 SwStyleSheetIterator::~SwStyleSheetIterator()
 {
-    EndListening( mxIterSheet->GetPool() );
+    EndListening( *mxIterSheet->GetPool() );
 }
 
 sal_uInt16  SwStyleSheetIterator::Count()


More information about the Libreoffice-commits mailing list