f6a91c9
From b9240ac3695c0f4b88c539721f13dc03b5afdabb Mon Sep 17 00:00:00 2001
f6a91c9
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolanm@redhat.com>
f6a91c9
Date: Tue, 1 Oct 2013 15:14:30 +0100
f6a91c9
Subject: [PATCH] Resolves: rhbz#1013480 crash in EditLineList::operator[]
f6a91c9
f6a91c9
avoid crashing anyway, though unknown how to end up in
f6a91c9
this scenario
f6a91c9
f6a91c9
Change-Id: Ib602c73478e5c4772cfef73f70c67ad22877a39f
f6a91c9
---
f6a91c9
 editeng/source/editeng/impedit2.cxx | 9 ++++++---
f6a91c9
 1 file changed, 6 insertions(+), 3 deletions(-)
f6a91c9
f6a91c9
diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
f6a91c9
index 4bc6d70..8dd3e35 100644
f6a91c9
--- a/editeng/source/editeng/impedit2.cxx
f6a91c9
+++ b/editeng/source/editeng/impedit2.cxx
f6a91c9
@@ -4119,10 +4119,13 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_uInt16 nIndex
f6a91c9
                         ? GetYValue( rLSItem.GetInterLineSpace() ) : 0;
f6a91c9
 
f6a91c9
     sal_uInt16 nCurIndex = 0;
f6a91c9
-    OSL_ENSURE( pPortion->GetLines().Count(), "Empty ParaPortion in GetEditCursor!" );
f6a91c9
+    size_t nLineCount = pPortion->GetLines().Count();
f6a91c9
+    OSL_ENSURE( nLineCount, "Empty ParaPortion in GetEditCursor!" );
f6a91c9
+    if (nLineCount == 0)
f6a91c9
+        return Rectangle();
f6a91c9
     const EditLine* pLine = NULL;
f6a91c9
     sal_Bool bEOL = ( nFlags & GETCRSR_ENDOFLINE ) ? sal_True : sal_False;
f6a91c9
-    for ( sal_uInt16 nLine = 0; nLine < pPortion->GetLines().Count(); nLine++ )
f6a91c9
+    for (size_t nLine = 0; nLine < nLineCount; ++nLine)
f6a91c9
     {
f6a91c9
         const EditLine* pTmpLine = pPortion->GetLines()[nLine];
f6a91c9
         if ( ( pTmpLine->GetStart() == nIndex ) || ( pTmpLine->IsIn( nIndex, bEOL ) ) )
f6a91c9
@@ -4141,7 +4144,7 @@ Rectangle ImpEditEngine::GetEditCursor( ParaPortion* pPortion, sal_uInt16 nIndex
f6a91c9
         // Cursor at the End of the paragraph.
f6a91c9
         OSL_ENSURE( nIndex == nCurIndex, "Index dead wrong in GetEditCursor!" );
f6a91c9
 
f6a91c9
-        pLine = pPortion->GetLines()[pPortion->GetLines().Count()-1];
f6a91c9
+        pLine = pPortion->GetLines()[nLineCount-1];
f6a91c9
         nY -= pLine->GetHeight();
f6a91c9
         if ( !aStatus.IsOutliner() )
f6a91c9
             nY -= nSBL;
f6a91c9
-- 
f6a91c9
1.8.3.1
f6a91c9