sc/source/core/data/dptabres.cxx | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
New commits: commit dbb0522741a88c878be9a89675e83bb79ddb7733 Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Tue Jun 14 10:51:13 2022 +0100 Commit: Caolán McNamara <caol...@redhat.com> CommitDate: Tue Jun 14 22:13:35 2022 +0200 crashtesting: crash seen on exporting forum-it-5909.ods to xlsx Change-Id: I64b629e2f5b0ece7f903049bd006775463f97586 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135751 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caol...@redhat.com> diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx index c29648d95d8b..d41604eee45e 100644 --- a/sc/source/core/data/dptabres.cxx +++ b/sc/source/core/data/dptabres.cxx @@ -2767,7 +2767,10 @@ ScDPResultDimension::~ScDPResultDimension() ScDPResultMember *ScDPResultDimension::FindMember( SCROW iData ) const { if( bIsDataLayout ) - return maMemberArray[0].get(); + { + SAL_WARN_IF(maMemberArray.empty(), "sc.core", "MemberArray is empty"); + return !maMemberArray.empty() ? maMemberArray[0].get() : nullptr; + } MemberHash::const_iterator aRes = maMemberHash.find( iData ); if( aRes != maMemberHash.end()) { @@ -2974,8 +2977,11 @@ void ScDPResultDimension::LateInitFrom( tools::Long ScDPResultDimension::GetSize(tools::Long nMeasure) const { - tools::Long nTotal = 0; tools::Long nMemberCount = maMemberArray.size(); + if (!nMemberCount) + return 0; + + tools::Long nTotal = 0; if (bIsDataLayout) { OSL_ENSURE(nMeasure == SC_DPMEASURE_ALL || pResultData->GetMeasureCount() == 1, @@ -3128,7 +3134,7 @@ void ScDPResultDimension::SortMembers( ScDPResultMember* pRefMember ) // handle children // for data layout, call only once - sorting measure is always taken from settings - tools::Long nLoopCount = bIsDataLayout ? 1 : nCount; + tools::Long nLoopCount = bIsDataLayout ? std::min<tools::Long>(1, nCount) : nCount; for (tools::Long i=0; i<nLoopCount; i++) { ScDPResultMember* pMember = maMemberArray[i].get();