sw/source/core/docnode/node.cxx |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

New commits:
commit 2140a0a95aa8e80d1c6d0abfe20ed1bed7b81717
Author:     Ashod Nakashian <ashod.nakash...@collabora.co.uk>
AuthorDate: Wed Jan 15 07:03:29 2025 -0500
Commit:     Miklos Vajna <vmik...@collabora.com>
CommitDate: Tue Jan 21 08:37:21 2025 +0100

    sw: safer SwContentNode::GoPrevious()
    
    Signed-off-by: Ashod Nakashian <ashod.nakash...@collabora.co.uk>
    Change-Id: I9719f237e3fd5483ee115bba411587c3a8fa8d86
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/180454
    Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com>
    Reviewed-by: Miklos Vajna <vmik...@collabora.com>

diff --git a/sw/source/core/docnode/node.cxx b/sw/source/core/docnode/node.cxx
index b2419bd132ec..4560ce9346f0 100644
--- a/sw/source/core/docnode/node.cxx
+++ b/sw/source/core/docnode/node.cxx
@@ -1339,12 +1339,14 @@ bool SwContentNode::GoNext(SwContentIndex * pIdx, 
SwCursorSkipMode nMode ) const
 bool SwContentNode::GoPrevious(SwContentIndex * pIdx, SwCursorSkipMode nMode ) 
const
 {
     bool bRet = true;
-    if( pIdx->GetIndex() > 0 )
+    assert(pIdx != nullptr && "Invalid SwContentIndex* argument to 
SwContentNode::GoPrevious()");
+    if (pIdx && pIdx->GetIndex() > 0)
     {
         if( !IsTextNode() )
             --(*pIdx);
         else
         {
+            assert(GetTextNode() != nullptr && "Expected valid GetTextNode() 
with IsTextNode()");
             const SwTextNode& rTNd = *GetTextNode();
             sal_Int32 nPos = pIdx->GetIndex();
             assert(g_pBreakIt && g_pBreakIt->GetBreakIter().is());

Reply via email to