editeng/source/editeng/impedit2.cxx |   23 +++++++++++++----------
 1 file changed, 13 insertions(+), 10 deletions(-)

New commits:
commit 9982510049417ce4e3969a492cfdecd3e5ed0760
Author: Eike Rathke <er...@redhat.com>
Date:   Wed Apr 26 14:30:03 2017 +0200

    check for nullptr, tdf#104265
    
    Crash not reproduced, but a nullptr is believed to be the cause as
    ParaPortionList::SafeGetObject() may return nullptr if a stray EditPaM
    was passed to ImpEditEngine::GetI18NScriptType()
    
    At least this matches
    
http://cgit.freedesktop.org/libreoffice/core/tree/editeng/source/editeng/impedit2.cxx?h=libreoffice-5-2-4#n1756
    given in
    
http://crashreport.libreoffice.org/stats/crash_details/725e8295-6dc0-4b0c-aff3-57c6c95930f2
    and
    
http://crashreport.libreoffice.org/stats/crash_details/e2570ac8-6137-4b67-91b2-6cc871f8cb69
    
    Change-Id: Id01983a31145442016da527a57024dc060060b1a
    (cherry picked from commit 17236fe21f9b0c734c0e8d5c371b8112dcab8ac0)
    Reviewed-on: https://gerrit.libreoffice.org/36989
    Tested-by: Jenkins <c...@libreoffice.org>
    Reviewed-by: Michael Stahl <mst...@redhat.com>

diff --git a/editeng/source/editeng/impedit2.cxx 
b/editeng/source/editeng/impedit2.cxx
index b38db62f411a..71694a77efaf 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -1741,18 +1741,21 @@ sal_uInt16 ImpEditEngine::GetI18NScriptType( const 
EditPaM& rPaM, sal_Int32* pEn
     {
         sal_Int32 nPara = GetEditDoc().GetPos( rPaM.GetNode() );
         const ParaPortion* pParaPortion = GetParaPortions().SafeGetObject( 
nPara );
-        if ( pParaPortion->aScriptInfos.empty() )
-            const_cast<ImpEditEngine*>(this)->InitScriptTypes( nPara );
+        if (pParaPortion)
+        {
+            if ( pParaPortion->aScriptInfos.empty() )
+                const_cast<ImpEditEngine*>(this)->InitScriptTypes( nPara );
 
-        const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos;
+            const ScriptTypePosInfos& rTypes = pParaPortion->aScriptInfos;
 
-        const sal_Int32 nPos = rPaM.GetIndex();
-        ScriptTypePosInfos::const_iterator itr = std::find_if(rTypes.begin(), 
rTypes.end(), FindByPos(nPos));
-        if(itr != rTypes.end())
-        {
-            nScriptType = itr->nScriptType;
-            if( pEndPos )
-                *pEndPos = itr->nEndPos;
+            const sal_Int32 nPos = rPaM.GetIndex();
+            ScriptTypePosInfos::const_iterator itr = 
std::find_if(rTypes.begin(), rTypes.end(), FindByPos(nPos));
+            if(itr != rTypes.end())
+            {
+                nScriptType = itr->nScriptType;
+                if( pEndPos )
+                    *pEndPos = itr->nEndPos;
+            }
         }
     }
     return nScriptType ? nScriptType : 
SvtLanguageOptions::GetI18NScriptTypeOfLanguage( GetDefaultLanguage() );
_______________________________________________
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to