From 599c06acb2d8bfc986eaac061aa4b7e2a5bab3c6 Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Tue, 13 Mar 2012 10:37:46 -0400 Subject: 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. --- sc/source/core/data/dpdimsave.cxx | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'sc/source/core/data/dpdimsave.cxx') 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 -- cgit v1.2.3