sc/source/filter/inc/condformatbuffer.hxx |    1 +
 sc/source/filter/oox/condformatbuffer.cxx |    8 ++++----
 2 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 04918259b55f97c338e95bf9a28f0279ef2168ae
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Mon Jan 15 20:41:49 2024 +0000
Commit:     Dennis Francis <dennis.fran...@collabora.com>
CommitDate: Wed Jan 17 13:48:27 2024 +0100

    ofz#65809 Direct-leak
    
    since:
    
    commit c84a1928ea76cf175711942db9ca7bb2f0ec6f0b
    Date:   Tue Oct 3 12:40:25 2023 +0530
    
        sc: condfmt-perf: use a shared cache that...
    
    mbReadyForFinalize gets set to true, but the mpFormat is never
    set into the ScDocument, add a mbOwnsFormat to track successful
    transfer of ownership.
    
    Change-Id: I8f11c68a4253d1ad67ec96825d5036ad468562ff
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/162136
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Dennis Francis <dennis.fran...@collabora.com>

diff --git a/sc/source/filter/inc/condformatbuffer.hxx 
b/sc/source/filter/inc/condformatbuffer.hxx
index 9c8896dbf22a..945a05d99e94 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -232,6 +232,7 @@ private:
     CondFormatRuleMap   maRules;            /// Maps formatting rules by 
priority.
     ScConditionalFormat* mpFormat;
     bool                mbReadyForFinalize;
+    bool                mbOwnsFormat;
 };
 
 struct ExCfRuleModel
diff --git a/sc/source/filter/oox/condformatbuffer.cxx 
b/sc/source/filter/oox/condformatbuffer.cxx
index b9f7bceec0e9..b065d96f00b7 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -1095,13 +1095,14 @@ CondFormatModel::CondFormatModel() :
 CondFormat::CondFormat( const WorksheetHelper& rHelper ) :
     WorksheetHelper( rHelper ),
     mpFormat(nullptr),
-    mbReadyForFinalize(false)
+    mbReadyForFinalize(false),
+    mbOwnsFormat(true)
 {
 }
 
 CondFormat::~CondFormat()
 {
-    if (!mbReadyForFinalize && mpFormat)
+    if (mbOwnsFormat)
         delete mpFormat;
 }
 
@@ -1147,12 +1148,11 @@ void CondFormat::finalizeImport()
     if (mpFormat->size() > 0)
     {
         SCTAB nTab = maModel.maRanges.GetTopLeftCorner().Tab();
+        mbOwnsFormat = false; // ownership transferred to std::unique_ptr -> 
ScDocument
         sal_Int32 nIndex = 
getScDocument().AddCondFormat(std::unique_ptr<ScConditionalFormat>(mpFormat), 
nTab);
 
         rDoc.AddCondFormatData( maModel.maRanges, nTab, nIndex );
     }
-    else
-        mbReadyForFinalize = false;
 }
 
 CondFormatRuleRef CondFormat::createRule()

Reply via email to