From ae4db7543fdec91ceb8a888d314b0d5feb6d386d Mon Sep 17 00:00:00 2001 From: Abdelrazak Younes Date: Wed, 28 Mar 2007 16:01:32 +0000 Subject: [PATCH] Fix bug 3356 by Bernhard Roider: The crash happens on alt+up and alt+down if the position of the cursor in the moved paragraph is beyond the length of the target paragraph. To avoid it the Position of the iterators for the target paragraph must be corrected. I set it to 0 as i assume it is not really used. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@17613 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/text3.C | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/text3.C b/src/text3.C index 94827a2713..6dac2facf7 100644 --- a/src/text3.C +++ b/src/text3.C @@ -333,6 +333,10 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) std::swap(pars_[pit], pars_[pit + 1]); ParIterator begin(cur); + // begin.pos() (== cur.pos()) may point beyond the end of the + // paragraph referenced by begin. This would cause a crash + // in updateLabels() + begin.pos() = 0; ++cur.pit(); ParIterator end = boost::next(ParIterator(cur)); updateLabels(cur.buffer(), begin, end); @@ -347,7 +351,12 @@ void LyXText::dispatch(LCursor & cur, FuncRequest & cmd) finishUndo(); std::swap(pars_[pit], pars_[pit - 1]); - ParIterator end = boost::next(ParIterator(cur)); + ParIterator end = ParIterator(cur); + // end.pos() (== cur.pos()) may point beyond the end of the + // paragraph referenced by end. This would cause a crash + // in boost::next() + end.pos() = 0; + end = boost::next(end); --cur.pit(); ParIterator begin(cur); updateLabels(cur.buffer(), begin, end); -- 2.39.5