Blame SOURCES/0001-Resolves-rhbz-1013480-crash-in-EditLineList-operator.patch

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