diff options
author | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-01-15 20:41:49 +0000 |
---|---|---|
committer | Caolán McNamara <caolan.mcnamara@collabora.com> | 2024-01-16 12:06:30 +0100 |
commit | 2188f940b0006e9ab421cae016f81fe366a4d649 (patch) | |
tree | bac6d0ff371514efe8005d3bc6575346b39a0cb7 | |
parent | 78f230713e1e1fd94f9fb1087bdba500fcf9231a (diff) |
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/+/162128
Tested-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
-rw-r--r-- | sc/source/filter/inc/condformatbuffer.hxx | 1 | ||||
-rw-r--r-- | sc/source/filter/oox/condformatbuffer.cxx | 8 |
2 files changed, 5 insertions, 4 deletions
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 919712e2f107..2626735023dd 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() |