crash with safe iterators: attempt to decrement a past-the-end iterator

Change-Id: I4c81125e67c23fb05e98fc6b2f47ed3e49dd29c3
This commit is contained in:
Ivan Timofeev
2012-09-02 15:04:08 +04:00
parent 1f08711bd1
commit 3e317451e3

View File

@@ -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