diff options
author | Caolán McNamara <caolanm@redhat.com> | 2022-01-18 21:12:10 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2022-01-19 09:36:21 +0100 |
commit | 9ae9b3b47c24556b2bc9a100b3bde33273018c5e (patch) | |
tree | 7d7aa8e58a0b1b983bfcacc665b38c28282d151f /sw | |
parent | 4a7281fa206c0a82cfc2ba23f25c31ae775d8777 (diff) |
ofz#43803 Null-dereference READ
git show -w is your friend
Change-Id: I2e451f3df4f093cb801dac0aaa61bc5a69aab0b1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128577
Tested-by: Caolán McNamara <caolanm@redhat.com>
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index ba06e730a70d..97b0a4752d17 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -4081,33 +4081,37 @@ bool SwWW8ImplReader::ReadText(WW8_CP nStartCp, WW8_CP nTextLen, ManTypes nType) if (SwTextNode* pPreviousNode = (bStartLine && m_xPreviousNode) ? m_xPreviousNode->GetTextNode() : nullptr) { SwTextNode* pEndNd = m_pPaM->GetNode().GetTextNode(); - const sal_Int32 nDropCapLen = pPreviousNode->GetText().getLength(); - - // Need to reset the font size and text position for the dropcap + SAL_WARN_IF(!pEndNd, "sw.ww8", "didn't find textnode for dropcap"); + if (pEndNd) { - SwPaM aTmp(*pEndNd, 0, *pEndNd, nDropCapLen+1); - m_xCtrlStck->Delete(aTmp); - } + const sal_Int32 nDropCapLen = pPreviousNode->GetText().getLength(); + + // Need to reset the font size and text position for the dropcap + { + SwPaM aTmp(*pEndNd, 0, *pEndNd, nDropCapLen+1); + m_xCtrlStck->Delete(aTmp); + } - // Get the default document dropcap which we can use as our template - const SwFormatDrop* defaultDrop = - static_cast<const SwFormatDrop*>( GetFormatAttr(RES_PARATR_DROP)); - SwFormatDrop aDrop(*defaultDrop); - - aDrop.GetLines() = nDropLines; - aDrop.GetDistance() = nDistance; - aDrop.GetChars() = writer_cast<sal_uInt8>(nDropCapLen); - // Word has no concept of a "whole word dropcap" - aDrop.GetWholeWord() = false; - - if (pFormat) - aDrop.SetCharFormat(const_cast<SwCharFormat*>(pFormat)); - else if(pNewSwCharFormat) - aDrop.SetCharFormat(pNewSwCharFormat); - - SwPosition aStart(*pEndNd); - m_xCtrlStck->NewAttr(aStart, aDrop); - m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_PARATR_DROP); + // Get the default document dropcap which we can use as our template + const SwFormatDrop* defaultDrop = + static_cast<const SwFormatDrop*>( GetFormatAttr(RES_PARATR_DROP)); + SwFormatDrop aDrop(*defaultDrop); + + aDrop.GetLines() = nDropLines; + aDrop.GetDistance() = nDistance; + aDrop.GetChars() = writer_cast<sal_uInt8>(nDropCapLen); + // Word has no concept of a "whole word dropcap" + aDrop.GetWholeWord() = false; + + if (pFormat) + aDrop.SetCharFormat(const_cast<SwCharFormat*>(pFormat)); + else if(pNewSwCharFormat) + aDrop.SetCharFormat(pNewSwCharFormat); + + SwPosition aStart(*pEndNd); + m_xCtrlStck->NewAttr(aStart, aDrop); + m_xCtrlStck->SetAttr(*m_pPaM->GetPoint(), RES_PARATR_DROP); + } m_xPreviousNode.reset(); } else if (m_bDropCap) |