summaryrefslogtreecommitdiff
path: root/sc
diff options
context:
space:
mode:
authorKohei Yoshida <kohei.yoshida@gmail.com>2012-12-14 22:34:38 -0500
committerKohei Yoshida <kohei.yoshida@gmail.com>2012-12-14 22:35:43 -0500
commit33c5cd785762f272d2a88230af48261342800c3f (patch)
treeb8635aba0c550e1412acc13fbd971b0ecd69c089 /sc
parent2d754521853b9ae89f4d9621150857f6592603b9 (diff)
Do extra check on source range to make sure no funny things happen.
Like a crash in the pivot layout dialog... :-/ Change-Id: I9a330ee3f39ebacb7299d24868bb13ee2a9c3ec5
Diffstat (limited to 'sc')
-rw-r--r--sc/source/core/data/dpcache.cxx5
-rw-r--r--sc/source/core/data/dpshttab.cxx8
2 files changed, 13 insertions, 0 deletions
diff --git a/sc/source/core/data/dpcache.cxx b/sc/source/core/data/dpcache.cxx
index afa4b1bc4252..cf03b0d3ad43 100644
--- a/sc/source/core/data/dpcache.cxx
+++ b/sc/source/core/data/dpcache.cxx
@@ -300,6 +300,11 @@ bool ScDPCache::InitFromDoc(ScDocument* pDoc, const ScRange& rRange)
SCROW nStartRow = rRange.aStart.Row(); // start of data
SCROW nEndRow = rRange.aEnd.Row();
+
+ // Sanity check
+ if (!ValidRow(nStartRow) || !ValidRow(nEndRow) || nEndRow-nStartRow <= 0)
+ return false;
+
sal_uInt16 nStartCol = rRange.aStart.Col();
sal_uInt16 nEndCol = rRange.aEnd.Col();
sal_uInt16 nDocTab = rRange.aStart.Tab();
diff --git a/sc/source/core/data/dpshttab.cxx b/sc/source/core/data/dpshttab.cxx
index b9de61fbf389..ccf4659cdf94 100644
--- a/sc/source/core/data/dpshttab.cxx
+++ b/sc/source/core/data/dpshttab.cxx
@@ -312,6 +312,14 @@ sal_uLong ScSheetSourceDesc::CheckSourceRange() const
if (!mpDoc)
return STR_ERR_DATAPILOTSOURCE;
+ // Make sure the range is valid and sane.
+ const ScRange& rSrcRange = GetSourceRange();
+ if (!rSrcRange.IsValid())
+ return STR_ERR_DATAPILOTSOURCE;
+
+ if (rSrcRange.aStart.Col() > rSrcRange.aEnd.Col() || rSrcRange.aStart.Row() > rSrcRange.aEnd.Row())
+ return STR_ERR_DATAPILOTSOURCE;
+
return 0;
}