sw/source/filter/ww8/ww8par.cxx |   54 +++++++++++++++++++++-------------------
 1 file changed, 29 insertions(+), 25 deletions(-)

New commits:
commit 9ae9b3b47c24556b2bc9a100b3bde33273018c5e
Author:     Caolán McNamara <caol...@redhat.com>
AuthorDate: Tue Jan 18 21:12:10 2022 +0000
Commit:     Caolán McNamara <caol...@redhat.com>
CommitDate: Wed Jan 19 09:36:21 2022 +0100

    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 <caol...@redhat.com>
    Reviewed-by: Caolán McNamara <caol...@redhat.com>

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)

Reply via email to