sc/source/ui/navipi/content.cxx |    2 +-
 sw/source/core/doc/docsort.cxx  |   21 +++++++++++----------
 2 files changed, 12 insertions(+), 11 deletions(-)

New commits:
commit 2c0157fbe9b9338f98e66d300664fe3c710eb415
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon Jun 3 20:09:16 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Jun 3 22:44:16 2024 +0200

    cid#1602449 Resource leak
    
    Change-Id: Ide5575adb3346a0ad36a484078dc02ef46a4c043
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168389
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <[email protected]>

diff --git a/sw/source/core/doc/docsort.cxx b/sw/source/core/doc/docsort.cxx
index df5aaf6e5c89..8f5e70d5110d 100644
--- a/sw/source/core/doc/docsort.cxx
+++ b/sw/source/core/doc/docsort.cxx
@@ -313,7 +313,7 @@ bool SwDoc::SortText(const SwPaM& rPaM, const 
SwSortOptions& rOpt)
     }
 
     std::optional<SwPaM> pRedlPam;
-    SwUndoRedlineSort* pRedlUndo = nullptr;
+    std::unique_ptr<SwUndoRedlineSort> xRedlUndo;
     SwUndoSort* pUndoSort = nullptr;
 
     // To-Do - add 'SwExtraRedlineTable' also ?
@@ -328,7 +328,7 @@ bool SwDoc::SortText(const SwPaM& rPaM, const 
SwSortOptions& rOpt)
         {
             if( bUndo )
             {
-                pRedlUndo = new SwUndoRedlineSort( *pRedlPam,rOpt );
+                xRedlUndo.reset(new SwUndoRedlineSort(*pRedlPam, rOpt));
                 GetIDocumentUndoRedo().DoUndo(false);
             }
             // First copy the range
@@ -356,8 +356,8 @@ bool SwDoc::SortText(const SwPaM& rPaM, const 
SwSortOptions& rOpt)
             if (pCNd)
                 pRedlPam->GetPoint()->SetContent( nCLen );
 
-            if( pRedlUndo )
-                pRedlUndo->SetValues( rPaM );
+            if (xRedlUndo)
+                xRedlUndo->SetValues(rPaM);
         }
         else
         {
@@ -380,7 +380,7 @@ bool SwDoc::SortText(const SwPaM& rPaM, const 
SwSortOptions& rOpt)
     SwNodeOffset nBeg = pStart->GetNodeIndex();
     SwNodeRange aRg( aStart, aStart );
 
-    if( bUndo && !pRedlUndo )
+    if (bUndo && !xRedlUndo)
     {
         pUndoSort = new SwUndoSort(rPaM, rOpt);
         GetIDocumentUndoRedo().AppendUndo(std::unique_ptr<SwUndo>(pUndoSort));
@@ -412,12 +412,13 @@ bool SwDoc::SortText(const SwPaM& rPaM, const 
SwSortOptions& rOpt)
 
     if( pRedlPam )
     {
-        if( pRedlUndo )
+        SwUndoRedlineSort* pRedlUndo = xRedlUndo.get();
+        if (pRedlUndo)
         {
-            pRedlUndo->SetSaveRange( *pRedlPam );
+            xRedlUndo->SetSaveRange(*pRedlPam);
             // UGLY: temp. enable Undo
             GetIDocumentUndoRedo().DoUndo(true);
-            GetIDocumentUndoRedo().AppendUndo( 
std::unique_ptr<SwUndo>(pRedlUndo) );
+            GetIDocumentUndoRedo().AppendUndo(std::move(xRedlUndo));
             GetIDocumentUndoRedo().DoUndo(false);
         }
 
@@ -437,13 +438,13 @@ bool SwDoc::SortText(const SwPaM& rPaM, const 
SwSortOptions& rOpt)
         // the sorted range is inserted
         getIDocumentRedlineAccess().AppendRedline( new SwRangeRedline( 
RedlineType::Insert, *pRedlPam ), true);
 
-        if( pRedlUndo )
+        if (pRedlUndo)
         {
             SwNodeIndex aInsEndIdx( pRedlPam->GetMark()->GetNode(), -1 );
             SwContentNode *const pContentNode = 
aInsEndIdx.GetNode().GetContentNode();
             pRedlPam->GetMark()->Assign( *pContentNode, pContentNode->Len() );
 
-            pRedlUndo->SetValues( *pRedlPam );
+            pRedlUndo->SetValues(*pRedlPam);
         }
 
         pRedlPam.reset();
commit 16b0ad3cf76d9932ebbd169af64b7ad292e68426
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon Jun 3 20:03:07 2024 +0100
Commit:     Caolán McNamara <[email protected]>
CommitDate: Mon Jun 3 22:44:08 2024 +0200

    cid#1459023 Dereference null return value
    
    Change-Id: I3ff5f121a76a30d07a80b46d469b669010318701
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/168388
    Reviewed-by: Caolán McNamara <[email protected]>
    Tested-by: Caolán McNamara <[email protected]>

diff --git a/sc/source/ui/navipi/content.cxx b/sc/source/ui/navipi/content.cxx
index 0ae1b45de7ee..c0e06a0f2b01 100644
--- a/sc/source/ui/navipi/content.cxx
+++ b/sc/source/ui/navipi/content.cxx
@@ -386,7 +386,7 @@ IMPL_LINK_NOARG(ScContentTree, ContentDoubleClickHdl, 
weld::TreeView&, bool)
                 pParentWindow->SetCurrentCell( aPos.Col(), aPos.Row() );
                 // Check whether the comment is currently visible and toggle 
its visibility
                 ScDocument* pSrcDoc = GetSourceDocument();
-                if (ScPostIt* pNote = pSrcDoc->GetNote(aPos.Col(), aPos.Row(), 
aPos.Tab()))
+                if (ScPostIt* pNote = pSrcDoc ? pSrcDoc->GetNote(aPos.Col(), 
aPos.Row(), aPos.Tab()) : nullptr)
                 {
                     bool bVisible = pNote->IsCaptionShown();
                     // Effectivelly set the visibility of the comment

Reply via email to