summaryrefslogtreecommitdiff
path: root/starmath
diff options
context:
space:
mode:
authorIvan Timofeev <timofeev.i.s@gmail.com>2012-09-02 15:04:08 +0400
committerIvan Timofeev <timofeev.i.s@gmail.com>2012-09-02 16:42:17 +0400
commit3e317451e319734d7e45cc431bd4b68ffe1a08f6 (patch)
treec71896f196bc78e9769e952406047e3ff97e4d2d /starmath
parent1f08711bd154d0502e5653088dc87575d4c372a7 (diff)
crash with safe iterators: attempt to decrement a past-the-end iterator
Change-Id: I4c81125e67c23fb05e98fc6b2f47ed3e49dd29c3
Diffstat (limited to 'starmath')
-rw-r--r--starmath/source/cursor.cxx23
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