[Libreoffice-commits] core.git: editeng/source

Eike Rathke erack at redhat.com
Wed Apr 26 12:38:33 UTC 2017


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

New commits:
commit 17236fe21f9b0c734c0e8d5c371b8112dcab8ac0
Author: Eike Rathke <erack at 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

diff --git a/editeng/source/editeng/impedit2.cxx b/editeng/source/editeng/impedit2.cxx
index 9e4072636e9a..71295dfe7022 100644
--- a/editeng/source/editeng/impedit2.cxx
+++ b/editeng/source/editeng/impedit2.cxx
@@ -1759,18 +1759,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() );


More information about the Libreoffice-commits mailing list