[Libreoffice-commits] core.git: Branch 'libreoffice-4-4' - sw/source

Michael Stahl mstahl at redhat.com
Fri Apr 24 00:26:56 PDT 2015


 sw/source/core/doc/docredln.cxx |   23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

New commits:
commit 6ccddc00775a5ec20b7b0bc35232ecbbbfd53958
Author: Michael Stahl <mstahl at redhat.com>
Date:   Wed Apr 22 14:28:38 2015 +0200

    rhbz#1198848: sw: delete *all* table redlines to fix DOCX import crash
    
    SwExtraRedlineTbl::DeleteAllTableRedlines() increments its position even
    when deleting the current element from the vector.
    
    Change-Id: Ie827a7b66fa9690bbabaf53204e9ec77247239f2
    (cherry picked from commit 28764d7ed5df874c2bfbc6025a97968e08cf2315)
    Reviewed-on: https://gerrit.libreoffice.org/15480
    Reviewed-by: Miklos Vajna <vmiklos at collabora.co.uk>
    Tested-by: Miklos Vajna <vmiklos at collabora.co.uk>

diff --git a/sw/source/core/doc/docredln.cxx b/sw/source/core/doc/docredln.cxx
index 91a2b58..bdec038 100644
--- a/sw/source/core/doc/docredln.cxx
+++ b/sw/source/core/doc/docredln.cxx
@@ -121,7 +121,7 @@ bool SwExtraRedlineTbl::DeleteAllTableRedlines( SwDoc* pDoc, const SwTable& rTab
         */
     }
 
-    for(sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < GetSize(); ++nCurRedlinePos )
+    for (sal_uInt16 nCurRedlinePos = 0; nCurRedlinePos < GetSize(); )
     {
         SwExtraRedline* pExtraRedline = GetRedline(nCurRedlinePos);
         const SwTableCellRedline* pTableCellRedline = dynamic_cast<const SwTableCellRedline*>(pExtraRedline);
@@ -136,11 +136,13 @@ bool SwExtraRedlineTbl::DeleteAllTableRedlines( SwDoc* pDoc, const SwTable& rTab
                 sal_uInt16 nRedlineType = aRedlineData.GetType();
 
                 // Check if this redline object type should be deleted
-                if( USHRT_MAX != nRedlineTypeToDelete && nRedlineTypeToDelete != nRedlineType )
-                    continue;
+                if (USHRT_MAX == nRedlineTypeToDelete || nRedlineTypeToDelete == nRedlineType)
+                {
 
-                DeleteAndDestroy( nCurRedlinePos );
-                bChg = true;
+                    DeleteAndDestroy( nCurRedlinePos );
+                    bChg = true;
+                    continue; // don't increment position after delete
+                }
             }
         }
         else
@@ -158,14 +160,17 @@ bool SwExtraRedlineTbl::DeleteAllTableRedlines( SwDoc* pDoc, const SwTable& rTab
                     sal_uInt16 nRedlineType = aRedlineData.GetType();
 
                     // Check if this redline object type should be deleted
-                    if( USHRT_MAX != nRedlineTypeToDelete && nRedlineTypeToDelete != nRedlineType )
-                        continue;
+                    if (USHRT_MAX == nRedlineTypeToDelete || nRedlineTypeToDelete == nRedlineType)
 
-                    DeleteAndDestroy( nCurRedlinePos );
-                    bChg = true;
+                    {
+                        DeleteAndDestroy( nCurRedlinePos );
+                        bChg = true;
+                        continue; // don't increment position after delete
+                    }
                 }
             }
         }
+        ++nCurRedlinePos;
     }
 
     if( bChg )


More information about the Libreoffice-commits mailing list