sw/qa/extras/ooxmlexport/data/tdf166436.docx    |binary
 sw/qa/extras/ooxmlexport/ooxmlexport15.cxx      |    9 +++++++++
 sw/source/writerfilter/dmapper/DomainMapper.cxx |    2 +-
 3 files changed, 10 insertions(+), 1 deletion(-)

New commits:
commit d72156ff0831c7ce240bb1fe1b542db5c54d1f37
Author:     Xisco Fauli <xiscofa...@libreoffice.org>
AuthorDate: Fri May 2 16:54:33 2025 +0200
Commit:     Xisco Fauli <xiscofa...@libreoffice.org>
CommitDate: Fri May 2 20:19:08 2025 +0200

    tdf#166436: check field stack is not empty
    
    like other places do
    
    Change-Id: I6fcb2bd849b11b0f17f1b19193a24c8e1f4ee660
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/184909
    Tested-by: Jenkins
    Reviewed-by: Xisco Fauli <xiscofa...@libreoffice.org>

diff --git a/sw/qa/extras/ooxmlexport/data/tdf166436.docx 
b/sw/qa/extras/ooxmlexport/data/tdf166436.docx
new file mode 100644
index 000000000000..6e824304006f
Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/tdf166436.docx differ
diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx 
b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
index 4ea70d6ab4db..2e7a8504f274 100644
--- a/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
+++ b/sw/qa/extras/ooxmlexport/ooxmlexport15.cxx
@@ -292,6 +292,15 @@ DECLARE_OOXMLEXPORT_TEST(testTdf138739, "tdf138739.docx")
     CPPUNIT_ASSERT_EQUAL(awt::FontWeight::BOLD, 
getProperty<float>(getRun(getParagraph(5), 3), u"CharWeight"_ustr));
 }
 
+CPPUNIT_TEST_FIXTURE(Test, testTdf166436)
+{
+    // Without the fix in place, this test would have crashed at import time
+    loadAndReload("tdf166436.docx");
+    uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, 
uno::UNO_QUERY);
+    uno::Reference<container::XEnumerationAccess> 
xFieldsAccess(xTextFieldsSupplier->getTextFields());
+    CPPUNIT_ASSERT(xFieldsAccess->hasElements());
+}
+
 CPPUNIT_TEST_FIXTURE(Test, testTdf123390)
 {
     loadAndReload("tdf123390.fodt");
diff --git a/sw/source/writerfilter/dmapper/DomainMapper.cxx 
b/sw/source/writerfilter/dmapper/DomainMapper.cxx
index 302ffdce589d..ad32fb4fe2ef 100644
--- a/sw/source/writerfilter/dmapper/DomainMapper.cxx
+++ b/sw/source/writerfilter/dmapper/DomainMapper.cxx
@@ -2741,7 +2741,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, const 
PropertyMapPtr& rContext )
                 }
             }
 
-            else if ( pSectionContext )
+            else if ( pSectionContext && m_pImpl->IsOpenField())
             {
                 FieldContextPtr pContext = m_pImpl->GetTopFieldContext();
                 rtl::Reference< SwXSection > xTOC = pContext->GetTOC();

Reply via email to