[Libreoffice-commits] core.git: cui/source include/sfx2 sc/source sfx2/source sw/source

Noel Grandin noel.grandin at collabora.co.uk
Tue Jun 12 13:14:22 UTC 2018


 cui/source/inc/numfmt.hxx         |    2 +-
 include/sfx2/app.hxx              |    6 +++---
 sc/source/ui/attrdlg/attrdlg.cxx  |    2 +-
 sc/source/ui/inc/attrdlg.hxx      |    2 +-
 sfx2/source/appl/appopen.cxx      |    3 +--
 sw/source/uibase/inc/navipi.hxx   |    2 +-
 sw/source/uibase/utlui/navipi.cxx |    4 ++--
 7 files changed, 10 insertions(+), 11 deletions(-)

New commits:
commit 59935c314945cdc365878a898317bfaa366fc36e
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jun 12 12:00:54 2018 +0200

    fix leak in SfxApplication::OpenDocExec_Impl
    
    when calling Link on SfxLinkItem, none of the callee sites free the
    memory associated with the Clone()'ed SfxPoolItem, so just skip the
    cloning, and make the Link take a const pointer to make this more
    obvious.
    
    Change-Id: Icd187e9d8d3ace9bf2e6ff183489999b105708e4
    Reviewed-on: https://gerrit.libreoffice.org/55671
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/cui/source/inc/numfmt.hxx b/cui/source/inc/numfmt.hxx
index 56e0fb8b8c92..80a3f296cba2 100644
--- a/cui/source/inc/numfmt.hxx
+++ b/cui/source/inc/numfmt.hxx
@@ -118,7 +118,7 @@ private:
     SvxNumberInfoItem*      pNumItem;
     SvxNumberFormatShell*   pNumFmtShell;
     sal_uLong               nInitFormat;
-    Link<SfxPoolItem*,void> fnOkHdl;
+    Link<SfxPoolItem const *,void> fnOkHdl;
 
     bool                bNumItemFlag; ///< for handling with DocShell
     bool                bOneAreaFlag;
diff --git a/include/sfx2/app.hxx b/include/sfx2/app.hxx
index b4d31614917b..a3299e9cde73 100644
--- a/include/sfx2/app.hxx
+++ b/include/sfx2/app.hxx
@@ -99,16 +99,16 @@ enum class SfxToolsModule
 
 class SFX2_DLLPUBLIC SfxLinkItem : public SfxPoolItem
 {
-    Link<SfxPoolItem*, void> aLink;
+    Link<SfxPoolItem const *, void> aLink;
 public:
-    SfxLinkItem( sal_uInt16 nWhichId, const Link<SfxPoolItem*, void>& rValue ) : SfxPoolItem( nWhichId )
+    SfxLinkItem( sal_uInt16 nWhichId, const Link<SfxPoolItem const *, void>& rValue ) : SfxPoolItem( nWhichId )
     {   aLink = rValue; }
 
     virtual SfxPoolItem*     Clone( SfxItemPool* = nullptr ) const override
     {   return new SfxLinkItem( *this ); }
     virtual bool             operator==( const SfxPoolItem& rL) const override
     {   return static_cast<const SfxLinkItem&>(rL).aLink == aLink; }
-    const Link<SfxPoolItem*, void>&
+    const Link<SfxPoolItem const *, void>&
                              GetValue() const { return aLink; }
 };
 
diff --git a/sc/source/ui/attrdlg/attrdlg.cxx b/sc/source/ui/attrdlg/attrdlg.cxx
index 9a4cfdba6155..3ad3c86f8747 100644
--- a/sc/source/ui/attrdlg/attrdlg.cxx
+++ b/sc/source/ui/attrdlg/attrdlg.cxx
@@ -86,7 +86,7 @@ void ScAttrDlg::PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage )
     }
 }
 
-IMPL_LINK_NOARG(ScAttrDlg, OkHandler, SfxPoolItem*, void)
+IMPL_LINK_NOARG(ScAttrDlg, OkHandler, SfxPoolItem const *, void)
 {
     GetOKButton().GetClickHdl().Call( nullptr );
 }
diff --git a/sc/source/ui/inc/attrdlg.hxx b/sc/source/ui/inc/attrdlg.hxx
index d32ff75ddeff..8d978def7738 100644
--- a/sc/source/ui/inc/attrdlg.hxx
+++ b/sc/source/ui/inc/attrdlg.hxx
@@ -37,7 +37,7 @@ protected:
     virtual void    PageCreated( sal_uInt16 nPageId, SfxTabPage& rTabPage ) override;
 
 private:
-    DECL_LINK( OkHandler, SfxPoolItem*, void ); // for closing by double clicking in TabPages
+    DECL_LINK( OkHandler, SfxPoolItem const *, void ); // for closing by double clicking in TabPages
     sal_uInt16 m_nNumberPageId;
     sal_uInt16 m_nFontPageId;
 };
diff --git a/sfx2/source/appl/appopen.cxx b/sfx2/source/appl/appopen.cxx
index 47ba55e34947..60f2c508ebbb 100644
--- a/sfx2/source/appl/appopen.cxx
+++ b/sfx2/source/appl/appopen.cxx
@@ -1122,8 +1122,7 @@ void SfxApplication::OpenDocExec_Impl( SfxRequest& rReq )
         const SfxPoolItem* pRetValue = rReq.GetReturnValue();
         if (pRetValue)
         {
-            SfxPoolItem* pClone = pRetValue->Clone();
-            pLinkItem->GetValue().Call(pClone);
+            pLinkItem->GetValue().Call(pRetValue);
         }
         delete pLinkItem;
     }
diff --git a/sw/source/uibase/inc/navipi.hxx b/sw/source/uibase/inc/navipi.hxx
index 590867472bcc..6bf64aac0675 100644
--- a/sw/source/uibase/inc/navipi.hxx
+++ b/sw/source/uibase/inc/navipi.hxx
@@ -111,7 +111,7 @@ class SwNavigationPI : public PanelLayout,
     DECL_LINK( ToolBoxDropdownClickHdl, ToolBox*, void );
     DECL_LINK( EditAction, NumEditAction&, void );
     DECL_LINK( EditGetFocus, Control&, void );
-    DECL_LINK( DoneLink, SfxPoolItem *, void );
+    DECL_LINK( DoneLink, SfxPoolItem const *, void );
     DECL_LINK( MenuSelectHdl, Menu *, bool );
     DECL_LINK( ChangePageHdl, Timer*, void );
     DECL_LINK( PageEditModifyHdl, SpinField&, void );
diff --git a/sw/source/uibase/utlui/navipi.cxx b/sw/source/uibase/utlui/navipi.cxx
index fe6f3dddafa9..7f265fda712e 100644
--- a/sw/source/uibase/utlui/navipi.cxx
+++ b/sw/source/uibase/utlui/navipi.cxx
@@ -1014,9 +1014,9 @@ void SwNavigationPI::UpdateListBox()
     m_aDocListBox->SetUpdateMode(true);
 }
 
-IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem *, pItem, void)
+IMPL_LINK(SwNavigationPI, DoneLink, SfxPoolItem const *, pItem, void)
 {
-    const SfxViewFrameItem* pFrameItem = dynamic_cast<SfxViewFrameItem*>( pItem  );
+    const SfxViewFrameItem* pFrameItem = dynamic_cast<SfxViewFrameItem const *>( pItem  );
     if( pFrameItem )
     {
         SfxViewFrame* pFrame =  pFrameItem->GetFrame();


More information about the Libreoffice-commits mailing list