summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-04-26 14:30:03 +0200
committerMichael Stahl <mstahl@redhat.com>2017-04-27 17:55:40 +0200
commit9982510049417ce4e3969a492cfdecd3e5ed0760 (patch)
treedab228f2c7964c817b5d44a977de8fce52648510
parent4df765766892a9148b7be1b8d5f174ee37cf73e0 (diff)
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 <ci@libreoffice.org> Reviewed-by: Michael Stahl <mstahl@redhat.com>
-rw-r--r--editeng/source/editeng/impedit2.cxx23
1 files changed, 13 insertions, 10 deletions
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() );