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

Noel Grandin (via logerrit) logerrit at kemper.freedesktop.org
Fri Jul 2 10:30:13 UTC 2021


 sc/source/ui/inc/pfuncache.hxx      |   14 +++++++-------
 sc/source/ui/unoobj/docuno.cxx      |   12 ++++++------
 sw/source/uibase/uiview/uivwimp.cxx |    2 ++
 3 files changed, 15 insertions(+), 13 deletions(-)

New commits:
commit 558dface96fbc5f487b16cfa1bf3c3ea20776331
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Jul 2 11:19:39 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 2 12:29:42 2021 +0200

    fix potential use-after-free in SwClipboardChangeListener
    
    we think we're seeing this in COOL
    
    Change-Id: I29a287b032158076a99a836d98113d1623ebef99
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118277
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sw/source/uibase/uiview/uivwimp.cxx b/sw/source/uibase/uiview/uivwimp.cxx
index 336ce8de1975..6ad240701960 100644
--- a/sw/source/uibase/uiview/uivwimp.cxx
+++ b/sw/source/uibase/uiview/uivwimp.cxx
@@ -287,6 +287,8 @@ SwClipboardChangeListener::~SwClipboardChangeListener()
 
 void SAL_CALL SwClipboardChangeListener::disposing( const EventObject& /*rEventObject*/ )
 {
+    SolarMutexGuard aGuard;
+    pView = nullptr; // so we don't touch the view if changedContents somehow fires afterwards
 }
 
 void SAL_CALL SwClipboardChangeListener::changedContents( const css::datatransfer::clipboard::ClipboardEvent& rEventObject )
commit e594c5e408593622bb70d54ef03ec5ca09a2d721
Author:     Noel Grandin <noel.grandin at collabora.co.uk>
AuthorDate: Fri Jul 2 10:50:47 2021 +0200
Commit:     Noel Grandin <noel.grandin at collabora.co.uk>
CommitDate: Fri Jul 2 12:29:34 2021 +0200

    convert ScPrintSelectionMode to scoped enum
    
    Change-Id: I94d2a4e371ebd8274c5b5c3f01eea70a77780e73
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118276
    Tested-by: Jenkins
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/sc/source/ui/inc/pfuncache.hxx b/sc/source/ui/inc/pfuncache.hxx
index 902ea7ade517..c3324e2f69f6 100644
--- a/sc/source/ui/inc/pfuncache.hxx
+++ b/sc/source/ui/inc/pfuncache.hxx
@@ -30,13 +30,13 @@ class OutputDevice;
 
 /** Possible types of selection for print functions */
 
-enum ScPrintSelectionMode
+enum class ScPrintSelectionMode
 {
-    SC_PRINTSEL_INVALID,
-    SC_PRINTSEL_DOCUMENT,
-    SC_PRINTSEL_CURSOR,
-    SC_PRINTSEL_RANGE,
-    SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS
+    Invalid,
+    Document,
+    Cursor,
+    Range,
+    RangeExclusivelyOleAndDrawObjects
 };
 
 /** Stores the selection in the ScPrintFuncCache so it is only used
@@ -49,7 +49,7 @@ class ScPrintSelectionStatus
     ScPrintOptions          aOptions;
 
 public:
-            ScPrintSelectionStatus() : eMode(SC_PRINTSEL_INVALID) {}
+            ScPrintSelectionStatus() : eMode(ScPrintSelectionMode::Invalid) {}
 
     void    SetMode(ScPrintSelectionMode eNew)  { eMode = eNew; }
     void    SetRanges(const ScRangeList& rNew)  { aRanges = rNew; }
diff --git a/sc/source/ui/unoobj/docuno.cxx b/sc/source/ui/unoobj/docuno.cxx
index 5f625839f490..0836e0e7ed7f 100644
--- a/sc/source/ui/unoobj/docuno.cxx
+++ b/sc/source/ui/unoobj/docuno.cxx
@@ -1577,10 +1577,10 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
                 if ( bCursor || bSheet )                // nothing selected -> use whole tables
                 {
                     rMark.ResetMark();      // doesn't change table selection
-                    rStatus.SetMode( SC_PRINTSEL_CURSOR );
+                    rStatus.SetMode( ScPrintSelectionMode::Cursor );
                 }
                 else
-                    rStatus.SetMode( SC_PRINTSEL_RANGE );
+                    rStatus.SetMode( ScPrintSelectionMode::Range );
 
                 rStatus.SetRanges( rRanges );
                 bDone = true;
@@ -1603,7 +1603,7 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
 
                 if( rMark.IsMarked() && !rMark.IsMultiMarked() )
                 {
-                    rStatus.SetMode( SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS );
+                    rStatus.SetMode( ScPrintSelectionMode::RangeExclusivelyOleAndDrawObjects );
                     bDone = true;
                 }
             }
@@ -1616,7 +1616,7 @@ bool ScModelObj::FillRenderMarkData( const uno::Any& aSelection,
             SCTAB nTabCount = pDocShell->GetDocument().GetTableCount();
             for (SCTAB nTab = 0; nTab < nTabCount; nTab++)
                 rMark.SelectTable( nTab, true );
-            rStatus.SetMode( SC_PRINTSEL_DOCUMENT );
+            rStatus.SetMode( ScPrintSelectionMode::Document );
             bDone = true;
         }
         // other selection types aren't supported
@@ -1744,7 +1744,7 @@ static sal_Int32 lcl_GetRendererNum( sal_Int32 nSelRenderer, const OUString& rPa
 
 static bool lcl_renderSelectionToGraphic( bool bRenderToGraphic, const ScPrintSelectionStatus& rStatus )
 {
-    return bRenderToGraphic && rStatus.GetMode() == SC_PRINTSEL_RANGE;
+    return bRenderToGraphic && rStatus.GetMode() == ScPrintSelectionMode::Range;
 }
 
 uno::Sequence<beans::PropertyValue> SAL_CALL ScModelObj::getRenderer( sal_Int32 nSelRenderer,
@@ -2148,7 +2148,7 @@ void SAL_CALL ScModelObj::render( sal_Int32 nSelRenderer, const uno::Any& aSelec
 
     pPrintFunc->SetDrawView( aDrawViewKeeper.mpDrawView.get() );
     pPrintFunc->SetRenderFlag( true );
-    if( aStatus.GetMode() == SC_PRINTSEL_RANGE_EXCLUSIVELY_OLE_AND_DRAW_OBJECTS )
+    if( aStatus.GetMode() == ScPrintSelectionMode::RangeExclusivelyOleAndDrawObjects )
         pPrintFunc->SetExclusivelyDrawOleAndDrawObjects();
 
     sal_Int32 nContent = 0;


More information about the Libreoffice-commits mailing list