diff options
author | Michael Stahl <mstahl@redhat.com> | 2011-11-18 14:54:48 +0100 |
---|---|---|
committer | Michael Stahl <mstahl@redhat.com> | 2011-11-18 22:24:20 +0100 |
commit | 9de2110e5bed17fcc6050bfaa669df45f0c1eb44 (patch) | |
tree | 8de79b3cc59f3fc0b5089b15e6847aca3d5f1431 /sw | |
parent | af0333e5865ecd184270af3211880d6d02307c31 (diff) |
SwCursor::RestoreSavePos: assert on invalid position
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/crsr/swcrsr.cxx | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/sw/source/core/crsr/swcrsr.cxx b/sw/source/core/crsr/swcrsr.cxx index 7340ccc1545a..a633bc0c7fa9 100644 --- a/sw/source/core/crsr/swcrsr.cxx +++ b/sw/source/core/crsr/swcrsr.cxx @@ -2093,21 +2093,27 @@ sal_Bool SwCursor::MoveSection( SwWhichSection fnWhichSect, void SwCursor::RestoreSavePos() { - // fdo#40831 if you delete the row or column containing pSavePos, - // Writer will crash. Work around this. + // This method is not supposed to be used in cases when nodes may be + // deleted; detect such cases, but do not crash (example: fdo#40831). sal_uLong uNodeCount = GetPoint()->nNode.GetNodes().Count(); + OSL_ENSURE(!pSavePos || pSavePos->nNode < uNodeCount, + "SwCursor::RestoreSavePos: invalid node: " + "probably something was deleted; consider using SwUnoCrsr instead"); if( pSavePos && pSavePos->nNode < uNodeCount ) { GetPoint()->nNode = pSavePos->nNode; xub_StrLen nIdx = 0; if ( GetCntntNode() ) + { if ( pSavePos->nCntnt <= GetCntntNode()->Len() ) nIdx = pSavePos->nCntnt; else + { nIdx = GetCntntNode()->Len(); - else - nIdx = GetPoint()->nContent.GetIndex(); // Probably, nIdx = 0 + OSL_FAIL("SwCursor::RestoreSavePos: invalid content index"); + } + } GetPoint()->nContent.Assign( GetCntntNode(), nIdx ); } } |