Author: af
Date: Mon Jul  1 15:10:21 2013
New Revision: 1498507

URL: http://svn.apache.org/r1498507
Log:
121479: Prevent crash when loading some RTF documents.

Modified:
    openoffice/trunk/main/sw/source/core/docnode/nodes.cxx

Modified: openoffice/trunk/main/sw/source/core/docnode/nodes.cxx
URL: 
http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/docnode/nodes.cxx?rev=1498507&r1=1498506&r2=1498507&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/docnode/nodes.cxx (original)
+++ openoffice/trunk/main/sw/source/core/docnode/nodes.cxx Mon Jul  1 15:10:21 
2013
@@ -522,6 +522,30 @@ sal_Bool SwNodes::_MoveNodes( const SwNo
        sal_uInt16 nSectNdCnt = 0;
        sal_Bool bSaveNewFrms = bNewFrms;
 
+    // Check that the range of nodes to move is valid.
+    // This is a very specific test that only checks that table nodes
+    // are completely covered by the range.  Issue 121479 has a
+    // document for which this test fails.    
+    SwNodeIndex aNodeIndex (aRg.aEnd);
+    while (aNodeIndex > aRg.aStart)
+    {
+        SwNode* pNode = rNodes[aNodeIndex.GetIndex()];
+        if (pNode->GetNodeType() != ND_ENDNODE)
+            break;
+        SwStartNode* pStartNode = pNode->pStartOfSection;
+        if (pStartNode==NULL)
+            break;
+        if ( ! pStartNode->IsTableNode())
+            break;
+        aNodeIndex = *pStartNode;
+        if (aNodeIndex < aRg.aStart.GetIndex())
+        {
+            return sal_False;
+        }
+        --aNodeIndex;
+    }
+
+
        // bis alles verschoben ist
        while( aRg.aStart < aRg.aEnd )
                switch( (pAktNode = &aRg.aEnd.GetNode())->GetNodeType() )


Reply via email to