sc/source/filter/oox/worksheethelper.cxx |   16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

New commits:
commit b3bd7eb60d403187ac2c483735b125baa866f55e
Author:     Caolán McNamara <caolan.mcnam...@collabora.com>
AuthorDate: Sun Aug 17 20:24:14 2025 +0100
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Mon Aug 18 18:00:05 2025 +0200

    null deref of StyleSheetPool seen
    
     #0  0x00007fca2fa09df2 in std::__shared_ptr<svl::IndexedStyleSheets, 
(__gnu_cxx::_Lock_policy)2>::get (this=<optimized out>)
         at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/shared_ptr_base.h:1665
     #1  std::__shared_ptr_access<svl::IndexedStyleSheets, 
(__gnu_cxx::_Lock_policy)2, false, false>::_M_get (this=<optimized out>)
         at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/shared_ptr_base.h:1363
     #2  std::__shared_ptr_access<svl::IndexedStyleSheets, 
(__gnu_cxx::_Lock_policy)2, false, false>::operator-> (
         this=<optimized out>) at 
/opt/rh/devtoolset-12/root/usr/include/c++/12/bits/shared_ptr_base.h:1357
     #3  SfxStyleSheetIterator::Find(rtl::OUString const&) () at 
svl/source/items/style.cxx:525
     #4  0x00007fca2fa0b406 in SfxStyleSheetBasePool::Find(rtl::OUString 
const&, SfxStyleFamily, SfxStyleSearchBits) [clone .localalias] () at 
svl/source/items/style.cxx:722
     #5  0x00007fca1f228c76 in oox::xls::CellStyle::createCellStyle() ()
         at include/unotools/resmgr.hxx:41
     #6  0x00007fca1f229c11 in oox::xls::CellStyleBuffer::createCellStyle (
         rxCellStyle=std::shared_ptr<oox::xls::CellStyle> (use count 3, weak 
count 0) = {...})
         at sc/source/filter/oox/stylesbuffer.cxx:2804
     #7  oox::xls::CellStyleBuffer::getDefaultStyleName (this=0x3c4ea458)
         at sc/source/filter/oox/stylesbuffer.cxx:2759
     #8  oox::xls::StylesBuffer::getDefaultStyleName (this=0x3c4ea350)
         at sc/source/filter/oox/stylesbuffer.cxx:3008
     #9  0x00007fca1f26c762 in 
oox::xls::WorksheetGlobals::initializeWorksheetImport() ()
         at sc/source/filter/oox/worksheethelper.cxx:923
     #10 0x00007fca1f26c7dd in 
oox::xls::WorksheetHelper::initializeWorksheetImport 
(this=this@entry=0x3c594168)
         at sc/source/filter/oox/worksheethelper.cxx:1614
     #11 0x00007fca1f262e34 in oox::xls::WorksheetFragment::initializeImport() 
()
        at sc/source/filter/oox/worksheetfragment.cxx:616
    
    Change-Id: I5bc25e361da17b811af4e552ca74b4becf0181ca
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/189831
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Mike Kaganski <mike.kagan...@collabora.com>

diff --git a/sc/source/filter/oox/worksheethelper.cxx 
b/sc/source/filter/oox/worksheethelper.cxx
index fe9dd4e9320d..6fd9bc5750ea 100644
--- a/sc/source/filter/oox/worksheethelper.cxx
+++ b/sc/source/filter/oox/worksheethelper.cxx
@@ -920,12 +920,16 @@ void WorksheetGlobals::initializeWorksheetImport()
     // set default cell style for unused cells
     ScDocumentImport& rDoc = getDocImport();
 
-    ScStyleSheet* pStyleSheet =
-        static_cast<ScStyleSheet*>(rDoc.getDoc().GetStyleSheetPool()->Find(
-            getStyles().getDefaultStyleName(), SfxStyleFamily::Para));
-
-    if (pStyleSheet)
-        rDoc.setCellStyleToSheet(getSheetIndex(), *pStyleSheet);
+    ScStyleSheetPool* pStylePool = rDoc.getDoc().GetStyleSheetPool();
+    SAL_WARN_IF(!pStylePool, "sc.filter", "Unusual lack of style pool");
+    if (pStylePool)
+    {
+        ScStyleSheet* pStyleSheet =
+            static_cast<ScStyleSheet*>(pStylePool->Find(
+                getStyles().getDefaultStyleName(), SfxStyleFamily::Para));
+        if (pStyleSheet)
+            rDoc.setCellStyleToSheet(getSheetIndex(), *pStyleSheet);
+    }
 
     /*  Remember the current sheet index in global data, needed by global
         objects, e.g. the chart converter. */

Reply via email to