diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-03-13 10:37:46 -0400 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2012-03-14 00:35:28 -0400 |
commit | 599c06acb2d8bfc986eaac061aa4b7e2a5bab3c6 (patch) | |
tree | 832e34fa28b0eb4819fdeca6a50f7c303671f9b3 /sc/source/core/data/dpdimsave.cxx | |
parent | fe01a68eaa55fa1ec32384be4c7b6b1863586dd0 (diff) |
Check the return value for negative index, to prevent crash.
Also, use at(index) when unsure about boundary condition. That makes
it easier to detect where illegal memory access is being done.
Diffstat (limited to 'sc/source/core/data/dpdimsave.cxx')
-rw-r--r-- | sc/source/core/data/dpdimsave.cxx | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sc/source/core/data/dpdimsave.cxx b/sc/source/core/data/dpdimsave.cxx index 9d02594e5f26..8cf8d39d94b2 100644 --- a/sc/source/core/data/dpdimsave.cxx +++ b/sc/source/core/data/dpdimsave.cxx @@ -395,12 +395,15 @@ void ScDPSaveGroupDimension::AddToData( ScDPGroupTableData& rData ) const void ScDPSaveGroupDimension::AddToCache(ScDPCache& rCache) const { + long nSourceDim = rCache.GetDimensionIndex(aSourceDim); + if (nSourceDim < 0) + return; + long nDim = rCache.AppendGroupField(); SvNumberFormatter* pFormatter = rCache.GetDoc()->GetFormatTable(); if (nDatePart) { - long nSourceDim = rCache.GetDimensionIndex(aSourceDim); fillDateGroupDimension(rCache, aDateInfo, nSourceDim, nDim, nDatePart, pFormatter); return; } @@ -416,7 +419,6 @@ void ScDPSaveGroupDimension::AddToCache(ScDPCache& rCache) const } } - long nSourceDim = rCache.GetDimensionIndex(aSourceDim); const ScDPCache::DataListType& rItems = rCache.GetDimMemberValues(nSourceDim); { ScDPCache::DataListType::const_iterator it = rItems.begin(), itEnd = rItems.end(); @@ -466,6 +468,9 @@ void ScDPSaveNumGroupDimension::AddToData( ScDPGroupTableData& rData ) const void ScDPSaveNumGroupDimension::AddToCache(ScDPCache& rCache) const { long nDim = rCache.GetDimensionIndex(aDimensionName); + if (nDim < 0) + return; + if (aDateInfo.mbEnable) { // Date grouping |