summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-06-14 10:51:13 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-06-14 16:01:40 +0200
commit51ed616b278b257a490bc52b69d0bf9ed8de1e4b (patch)
treed17f4f1b0820bd35ccfc8e7571054297404a03a3 /sc
parent66b849eab05bb6b696cced84ca90c17ca1bc31dd (diff)
crashtesting: crash seen on exporting forum-it-5909.ods to xlsx
Change-Id: I64b629e2f5b0ece7f903049bd006775463f97586 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135818 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
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 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();