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

New commits:
commit 61609fe6a7b6acb51a4e9e9711012a3a7ce3f2b6
Author:     Henry Castro <hcas...@collabora.com>
AuthorDate: Mon Jun 26 10:43:34 2023 -0400
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Wed Jun 28 10:48:38 2023 +0200

    sc: filter: oox: fix crash delete ScDatabarFormatData
    
    Unfortunately, the instance of "ScDatabarFormatData" is
    deleted before finalizeImport is called.
    
    The "maEntries" is not usable, the global format buffer is
    required to hold the reference.
    
     #1 0x7f2ef19081c0 in oox::xls::CondFormatBuffer::finalizeImport() 
co-23.05-asan/sc/source/filter/oox/condformatbuffer.cxx:1322:23
        #2 0x7f2ef1b9999a in 
oox::xls::WorksheetGlobals::finalizeWorksheetImport() 
co-23.05-asan/sc/source/filter/oox/worksheethelper.cxx:942:22
        #3 0x7f2ef58d030e in 
sax_fastparser::FastSaxParserImpl::parseStream(com::sun::star::xml::sax::InputSource
 const&) co-23.05-asan/sax/source/fastparser/fastparser.cxx:910:36
        #4 0x7f2ef23f0e46 in 
oox::core::FastParser::parseStream(com::sun::star::xml::sax::InputSource 
const&, bool) co-23.05-asan/oox/source/core/fastparser.cxx:121:15
        #5 0x7f2ef23f1544 in
    
    Signed-off-by: Henry Castro <hcas...@collabora.com>
    Change-Id: Ieb3840cc10372867d5462a19d9efa9771f633437
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153601
    Tested-by: Jenkins
    Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com>
    Signed-off-by: Xisco Fauli <xiscofa...@libreoffice.org>
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/153683

diff --git a/sc/source/filter/inc/condformatbuffer.hxx 
b/sc/source/filter/inc/condformatbuffer.hxx
index e62917678b9a..9c8896dbf22a 100644
--- a/sc/source/filter/inc/condformatbuffer.hxx
+++ b/sc/source/filter/inc/condformatbuffer.hxx
@@ -307,6 +307,7 @@ public:
     CondFormatRef       importCondFormatting( SequenceInputStream& rStrm );
     ExtCfDataBarRuleRef createExtCfDataBarRule(ScDataBarFormatData* pTarget);
     std::vector< std::unique_ptr<ExtCfCondFormat> >& importExtCondFormat();
+    std::vector<std::unique_ptr<ScFormatEntry> >& importExtFormatEntries();
 
     /** Converts an OOXML condition operator token to the API constant. */
     static sal_Int32    convertToApiOperator( sal_Int32 nToken );
@@ -324,6 +325,7 @@ private:
     CondFormatVec       maCondFormats;      /// All conditional formatting in 
a sheet.
     ExtCfDataBarRuleVec        maCfRules;          /// All external 
conditional formatting rules in a sheet.
     std::vector< std::unique_ptr<ExtCfCondFormat> > maExtCondFormats;
+    std::vector<std::unique_ptr<ScFormatEntry> > maExtFormatEntries;
     sal_Int32 mnNonPrioritizedRuleNextPriority = 1048576;
 };
 
diff --git a/sc/source/filter/oox/condformatbuffer.cxx 
b/sc/source/filter/oox/condformatbuffer.cxx
index 75171441c23d..649c2417f348 100644
--- a/sc/source/filter/oox/condformatbuffer.cxx
+++ b/sc/source/filter/oox/condformatbuffer.cxx
@@ -1376,6 +1376,11 @@ std::vector< std::unique_ptr<ExtCfCondFormat> >& 
CondFormatBuffer::importExtCond
     return maExtCondFormats;
 }
 
+std::vector<std::unique_ptr<ScFormatEntry> >& 
CondFormatBuffer::importExtFormatEntries()
+{
+    return maExtFormatEntries;
+}
+
 sal_Int32 CondFormatBuffer::convertToApiOperator( sal_Int32 nToken )
 {
     switch( nToken )
diff --git a/sc/source/filter/oox/extlstcontext.cxx 
b/sc/source/filter/oox/extlstcontext.cxx
index 3209c846f9ce..58e4c7931729 100644
--- a/sc/source/filter/oox/extlstcontext.cxx
+++ b/sc/source/filter/oox/extlstcontext.cxx
@@ -174,7 +174,7 @@ ContextHandlerRef 
ExtConditionalFormattingContext::onCreateContext(sal_Int32 nEl
                 {
                     auto pFormat = 
std::make_unique<ScDataBarFormat>(&getScDocument());
                     pFormat->SetDataBarData(pInfo);
-                    maEntries.push_back(std::move(pFormat));
+                    
getCondFormats().importExtFormatEntries().push_back(std::move(pFormat));
                 }
             }
             else

Reply via email to