sc/inc/dptabsrc.hxx | 2 +- sc/source/core/data/dptabsrc.cxx | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-)
New commits: commit 3536fcd999f16525f20a1fff5c2512b565511d7b Author: Eike Rathke <er...@redhat.com> Date: Tue Jul 24 10:53:33 2012 +0200 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 diff --git a/sc/inc/dptabsrc.hxx b/sc/inc/dptabsrc.hxx index b69846b..9fced30 100644 --- a/sc/inc/dptabsrc.hxx +++ b/sc/inc/dptabsrc.hxx @@ -755,7 +755,7 @@ public: rtl::OUString GetNameStr() const; void FillItemData( ScDPItemData& rData ) const; - const ScDPItemData& GetItemData() const; + const ScDPItemData* GetItemData() const; SCROW GetItemDataId() const { return mnDataId; } bool IsNamedItem(SCROW nIndex) const; diff --git a/sc/source/core/data/dptabsrc.cxx b/sc/source/core/data/dptabsrc.cxx index 8b7d6f8..039fa58 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) _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits