summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-06-14 10:51:13 +0100
committerXisco Fauli <xiscofauli@libreoffice.org>2022-06-14 21:28:08 +0200
commit8e14296fcf11bafe91f3ec45598841ba117b20b8 (patch)
tree4cced6c845967e526433e3a1d3b6c428be3bee78 /sc
parentc935e6d68c06e50fb8de81a8497b4d9a9c5dda1f (diff)
crashtesting: crash seen on exporting forum-it-5909.ods to xlsx
Change-Id: I64b629e2f5b0ece7f903049bd006775463f97586 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135752 Tested-by: Jenkins Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/dptabres.cxx12
1 files changed, 9 insertions, 3 deletions
diff --git a/sc/source/core/data/dptabres.cxx b/sc/source/core/data/dptabres.cxx
index e49fbd365b44..f17e1b51eb44 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();