summaryrefslogtreecommitdiff
path: root/sc/source/core/data/dptabsrc.cxx
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2012-07-24 10:53:33 +0200
committerEike Rathke <erack@redhat.com>2012-07-24 11:12:21 +0200
commit3536fcd999f16525f20a1fff5c2512b565511d7b (patch)
tree04207644167d26cb07b0b0242911945206496d36 /sc/source/core/data/dptabsrc.cxx
parentdbbc38c174e8a924e2f26b9c21c84cccd17b8d08 (diff)
prevent crash in malformed pivot table loaded from .xls
ScDPMember::GetItemData() unconditionally returned a reference to a ScDPItemData pointer obtained through ScDPSource::GetItemDataById() ScDPTableData::GetMemberById() ScDPCache::GetItemDataById() that can be null for malformed entries. Changed ScDPMember::GetItemData() to return a pointer instead and adapted callers to check for null. 3.5.x in ScDPSource::GetItemDataById() had a check for null pointer and added an empty ScDPItemData element to the cache for this case and returned the pointer to that entry (marked as todo). This is not the case anymore. Change-Id: I241c232d7182f5d58e8531af540e69b26ab4888a
Diffstat (limited to 'sc/source/core/data/dptabsrc.cxx')
-rw-r--r--sc/source/core/data/dptabsrc.cxx17
1 files changed, 12 insertions, 5 deletions
diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx
index 8b7d6f8cb90c..039fa5897fc6 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -2577,7 +2577,8 @@ bool ScDPMember::IsNamedItem(SCROW nIndex) const
(long)::rtl::math::approxFloor( pData->GetValue() ),
nHier, nLev );
// fValue is converted from integer, so simple comparison works
- return nComp == GetItemData().GetValue();
+ const ScDPItemData* pData2 = GetItemData();
+ return pData && nComp == pData2->GetValue();
}
}
@@ -2613,7 +2614,8 @@ void ScDPMember::FillItemData( ScDPItemData& rData ) const
{
//! handle date hierarchy...
- rData = GetItemData() ;
+ const ScDPItemData* pData = GetItemData();
+ rData = (pData ? *pData : ScDPItemData());
}
const OUString* ScDPMember::GetLayoutName() const
@@ -2628,7 +2630,10 @@ long ScDPMember::GetDim() const
rtl::OUString ScDPMember::GetNameStr() const
{
- return pSource->GetData()->GetFormattedString(nDim, GetItemData());
+ const ScDPItemData* pData = GetItemData();
+ if (pData)
+ return pSource->GetData()->GetFormattedString(nDim, *pData);
+ return rtl::OUString();
}
::rtl::OUString SAL_CALL ScDPMember::getName() throw(uno::RuntimeException)
@@ -2723,9 +2728,11 @@ const ScDPCache* ScDPSource::GetCache()
return ( GetData()!=NULL) ? GetData()->GetCacheTable().getCache() : NULL ;
}
-const ScDPItemData& ScDPMember::GetItemData() const
+const ScDPItemData* ScDPMember::GetItemData() const
{
- return *pSource->GetItemDataById(nDim, mnDataId);
+ const ScDPItemData* pData = pSource->GetItemDataById(nDim, mnDataId);
+ SAL_WARN_IF( !pData, "sc", "ScDPMember::GetItemData: what data? nDim " << nDim << ", mnDataId " << mnDataId);
+ return pData;
}
const ScDPItemData* ScDPSource::GetItemDataById(long nDim, long nId)