[Libreoffice-commits] .: Branch 'libreoffice-3-6' - sc/inc sc/source
Stephan Bergmann
sbergmann at kemper.freedesktop.org
Tue Jul 24 05:56:27 PDT 2012
sc/inc/dptabsrc.hxx | 2 +-
sc/source/core/data/dptabsrc.cxx | 17 ++++++++++++-----
2 files changed, 13 insertions(+), 6 deletions(-)
New commits:
commit ca9607ac8ed43d29125a0a2d22a938ec8f414841
Author: Eike Rathke <erack at 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.
(cherry picked from commit 3536fcd999f16525f20a1fff5c2512b565511d7b
plus follow-up 9b2ec8c2a3478047a270b31bc25ad1d782401306 "it's pData2")
Change-Id: I241c232d7182f5d58e8531af540e69b26ab4888a
Signed-off-by: Stephan Bergmann <sbergman at redhat.com>
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 4d680ae..bbf9217 100644
--- a/sc/source/core/data/dptabsrc.cxx
+++ b/sc/source/core/data/dptabsrc.cxx
@@ -2583,7 +2583,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 pData2 && nComp == pData2->GetValue();
}
}
@@ -2619,7 +2620,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
@@ -2634,7 +2636,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)
@@ -2729,9 +2734,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)
More information about the Libreoffice-commits
mailing list