diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2020-10-02 15:27:46 +0200 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2020-10-04 15:10:05 +0200 |
commit | adab4dcb1ea11246f29f43edb2f3c0c588014b2b (patch) | |
tree | 0d4838cf3ed49add6d1b4d58d27f2d02c807c61d /sw | |
parent | 73576d93ebec33a97d8a13bfd8d1f374438b414b (diff) |
related: tdf#127579: make use of FindCharFormatByName more robust
the same way it's done in WW8AttributeOutput::TextINetFormat
This might fix crashes like
https://crashreport.libreoffice.org/stats/crash_details/3538a470-23d7-4e37-9504-fe6e81da301b
unfortunatelly, I have no steps to reproduce it at the moment
Change-Id: I509ee439643dfbaf6f08477142bbbd171e13eed8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103859
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index 1f2c6f99364c..7d2a1c0432d3 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -222,11 +222,27 @@ void MSWordExportBase::ExportPoolItemsToCHP( ww8::PoolItems &rItems, sal_uInt16 if (nWhich == RES_TXTATR_CHARFMT) { const SfxPoolItem* pINetItem = SearchPoolItems(rItems, RES_TXTATR_INETFMT); + if (pINetItem) { + const SwFormatINetFormat& rINet = static_cast<const SwFormatINetFormat&>(*pINetItem); + + if ( rINet.GetValue().isEmpty() ) + continue; + + const sal_uInt16 nId = rINet.GetINetFormatId(); + const OUString& rStr = rINet.GetINetFormat(); + + if (rStr.isEmpty()) + { + OSL_ENSURE( false, "MSWordExportBase::ExportPoolItemsToCHP(..) - missing unvisited character format at hyperlink attribute" ); + } + + const SwCharFormat* pINetFormat = IsPoolUserFormat( nId ) + ? m_rDoc.FindCharFormatByName( rStr ) + : m_rDoc.getIDocumentStylePoolAccess().GetCharFormatFromPool( nId ); + const SwCharFormat* pFormat = static_cast<const SwFormatCharFormat&>(*pItem).GetCharFormat(); - const SwCharFormat* pINetFormat = m_rDoc.FindCharFormatByName( - static_cast<const SwFormatINetFormat&>(*pINetItem).GetINetFormat()); ww8::PoolItems aCharItems, aINetItems; GetPoolItems(pFormat->GetAttrSet(), aCharItems, false); GetPoolItems(pINetFormat->GetAttrSet(), aINetItems, false); |