sw/source/filter/ww8/docxattributeoutput.cxx | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-)
New commits: commit 77fc0c157de024fbf33db90952a92bf9bb73a9ac Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Fri Oct 14 15:19:52 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Sat Oct 15 13:57:30 2022 +0200 cid#1515941 Dereference null return value Change-Id: I61695d1689cfcef9c04d38b6ef07912840f250bb Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141378 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index f2489186e9c5..f6c8ff6902b9 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -2465,20 +2465,24 @@ void DocxAttributeOutput::WriteContentControlStart() const OUString& rPrefixMapping = m_pContentControl->GetDataBindingPrefixMappings(); const OUString& rXpath = m_pContentControl->GetDataBindingXpath(); - if (SwTextNode* pTextNode = !rXpath.isEmpty() ? m_pContentControl->GetTextNode() : nullptr) + if (!rXpath.isEmpty()) { // This content control has a data binding, update the data source. SwTextContentControl* pTextAttr = m_pContentControl->GetTextAttr(); - SwPosition aPoint(*pTextNode, pTextAttr->GetStart()); - SwPosition aMark(*pTextNode, *pTextAttr->GetEnd()); - SwPaM aPam(aMark, aPoint); - OUString aSnippet = aPam.GetText(); - static sal_Unicode const aForbidden[] = { - CH_TXTATR_BREAKWORD, - 0 - }; - aSnippet = comphelper::string::removeAny(aSnippet, aForbidden); - m_rExport.AddSdtData(rPrefixMapping, rXpath, aSnippet); + SwTextNode* pTextNode = m_pContentControl->GetTextNode(); + if (pTextNode && pTextAttr) + { + SwPosition aPoint(*pTextNode, pTextAttr->GetStart()); + SwPosition aMark(*pTextNode, *pTextAttr->GetEnd()); + SwPaM aPam(aMark, aPoint); + OUString aSnippet = aPam.GetText(); + static sal_Unicode const aForbidden[] = { + CH_TXTATR_BREAKWORD, + 0 + }; + aSnippet = comphelper::string::removeAny(aSnippet, aForbidden); + m_rExport.AddSdtData(rPrefixMapping, rXpath, aSnippet); + } } m_pContentControl = nullptr;