diff options
author | Ivan Timofeev <timofeev.i.s@gmail.com> | 2012-09-02 15:04:08 +0400 |
---|---|---|
committer | Ivan Timofeev <timofeev.i.s@gmail.com> | 2012-09-02 16:42:17 +0400 |
commit | 3e317451e319734d7e45cc431bd4b68ffe1a08f6 (patch) | |
tree | c71896f196bc78e9769e952406047e3ff97e4d2d /starmath/source | |
parent | 1f08711bd154d0502e5653088dc87575d4c372a7 (diff) |
crash with safe iterators: attempt to decrement a past-the-end iterator
Change-Id: I4c81125e67c23fb05e98fc6b2f47ed3e49dd29c3
Diffstat (limited to 'starmath/source')
-rw-r--r-- | starmath/source/cursor.cxx | 23 |
1 files changed, 13 insertions, 10 deletions
diff --git a/starmath/source/cursor.cxx b/starmath/source/cursor.cxx index ed81f1e47538..9edb83ea1e2f 100644 --- a/starmath/source/cursor.cxx +++ b/starmath/source/cursor.cxx @@ -205,18 +205,21 @@ void SmCursor::DeletePrev(OutputDevice* pDev){ //Line to merge things into, so we can delete pLine SmNode* pMergeLine = pLineParent->GetSubNode(nLineOffset-1); OSL_ENSURE(pMergeLine, "pMergeLine cannot be NULL!"); + SmCaretPos PosAfterDelete; //Convert first line to list SmNodeList *pLineList = NodeToList(pMergeLine); - //Find iterator to patch - SmNodeList::iterator patchPoint = pLineList->end(); - --patchPoint; - //Convert second line to list - NodeToList(pLine, pLineList); - //Patch the line list - ++patchPoint; - SmCaretPos PosAfterDelete = PatchLineList(pLineList, patchPoint); - //Parse the line - pLine = SmNodeListParser().Parse(pLineList); + if(!pLineList->empty()){ + //Find iterator to patch + SmNodeList::iterator patchPoint = pLineList->end(); + --patchPoint; + //Convert second line to list + NodeToList(pLine, pLineList); + //Patch the line list + ++patchPoint; + PosAfterDelete = PatchLineList(pLineList, patchPoint); + //Parse the line + pLine = SmNodeListParser().Parse(pLineList); + } delete pLineList; pLineParent->SetSubNode(nLineOffset-1, pLine); //Delete the removed line slot |