diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2024-03-13 14:07:50 +0100 |
---|---|---|
committer | Andras Timar <andras.timar@collabora.com> | 2024-03-17 20:42:33 +0100 |
commit | 4fa5c7400572f46ac88007a7d712a36e7bf53277 (patch) | |
tree | bf97420fa6c4f2ff2777c9126dd2b3616aedd346 /sw | |
parent | 34e29a5c3bfe852c74db8c2949c4cd419c8e50d2 (diff) |
sw: fix fieldmark crash in MSWordExportBase::OutputTextNode()
Crashreport signature:
program/libmswordlo.so
MSWordExportBase::OutputTextNode(SwTextNode&)
sw/source/filter/ww8/wrtw8nds.cxx:2547
program/libmswordlo.so
MSWordExportBase::WriteText()
sw/source/filter/ww8/wrtww8.cxx:2936
program/libmswordlo.so
DocxExport::WriteMainText()
/opt/rh/devtoolset-10/root/usr/include/c++/10/bits/stl_tree.h:1261
program/libmswordlo.so
DocxExport::ExportDocument_Impl()
sw/source/filter/ww8/docxexport.cxx:541
Keep the assert, because ideally it should not happen that we have no
fieldmark at CH_TXT_ATR_FIELDEND, but crashing in non-debug builds goes
a bit too far.
Change-Id: I428f46821771802a0ea2beaaf86463487e561aff
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164844
Tested-by: Jenkins
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
(cherry picked from commit 27a41c7e4ec0e82e2ed0ca2577574f5295a16057)
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164825
Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/wrtw8nds.cxx | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx index 68437c9529b3..e33e8708f453 100644 --- a/sw/source/filter/ww8/wrtw8nds.cxx +++ b/sw/source/filter/ww8/wrtw8nds.cxx @@ -2658,33 +2658,36 @@ void MSWordExportBase::OutputTextNode( SwTextNode& rNode ) assert(pFieldmark); - if (pFieldmark->GetFieldname() == ODF_FORMDATE) + if (pFieldmark) { - if(GetExportFormat() == MSWordExportBase::ExportFormat::DOCX) // supported by DOCX only + if (pFieldmark->GetFieldname() == ODF_FORMDATE) { - OutputField( nullptr, ww::eFORMDATE, OUString(), FieldFlags::Close ); + if(GetExportFormat() == MSWordExportBase::ExportFormat::DOCX) // supported by DOCX only + { + OutputField( nullptr, ww::eFORMDATE, OUString(), FieldFlags::Close ); + } } - } - else - { - ww::eField eFieldId = lcl_getFieldId( pFieldmark ); - if (pFieldmark->GetFieldname() == ODF_UNHANDLED) + else { - IFieldmark::parameter_map_t::const_iterator it = pFieldmark->GetParameters()->find( ODF_ID_PARAM ); - if ( it != pFieldmark->GetParameters()->end() ) + ww::eField eFieldId = lcl_getFieldId( pFieldmark ); + if (pFieldmark->GetFieldname() == ODF_UNHANDLED) { - OUString sFieldId; - it->second >>= sFieldId; - eFieldId = static_cast<ww::eField>(sFieldId.toInt32()); + IFieldmark::parameter_map_t::const_iterator it = pFieldmark->GetParameters()->find( ODF_ID_PARAM ); + if ( it != pFieldmark->GetParameters()->end() ) + { + OUString sFieldId; + it->second >>= sFieldId; + eFieldId = static_cast<ww::eField>(sFieldId.toInt32()); + } } - } - OutputField( nullptr, eFieldId, OUString(), FieldFlags::Close ); + OutputField( nullptr, eFieldId, OUString(), FieldFlags::Close ); - if (pFieldmark->GetFieldname() == ODF_FORMTEXT - && GetExportFormat() != MSWordExportBase::ExportFormat::DOCX ) - { - AppendBookmark( pFieldmark->GetName() ); + if (pFieldmark->GetFieldname() == ODF_FORMTEXT + && GetExportFormat() != MSWordExportBase::ExportFormat::DOCX ) + { + AppendBookmark( pFieldmark->GetName() ); + } } } } |