diff options
author | Xisco Fauli <xiscofauli@libreoffice.org> | 2022-06-10 10:04:15 +0200 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2022-06-10 14:02:32 +0200 |
commit | 629a9b92da6d0126bd4be4cde373a02ac542ce7d (patch) | |
tree | 08ad9e2931613b4b3d54640b53240601d0a520c1 /sc | |
parent | 3a688ca467cebd65ef30ab80d4211715b1665348 (diff) |
tdf#149503: Check size of vectors
Crash introduced by 41f95c4a35a6335e9edb2f51c11d136d88bd0749
"Remove SC_DPOUT_MAXLEVELS limit in Pivot"
This brings back the old behaviour and now the
"You cannot change this part of the pivot table." message
is displayed again
Change-Id: Ibad84c0a279d7d67b709b7e311ac875739cdb210
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135578
Tested-by: Eike Rathke <erack@redhat.com>
Reviewed-by: Eike Rathke <erack@redhat.com>
Diffstat (limited to 'sc')
-rw-r--r-- | sc/CppunitTest_sc_uicalc.mk | 5 | ||||
-rw-r--r-- | sc/qa/unit/uicalc/data/tdf149503.xls | bin | 0 -> 43008 bytes | |||
-rw-r--r-- | sc/qa/unit/uicalc/uicalc.cxx | 21 | ||||
-rw-r--r-- | sc/source/core/data/dpoutput.cxx | 4 |
4 files changed, 29 insertions, 1 deletions
diff --git a/sc/CppunitTest_sc_uicalc.mk b/sc/CppunitTest_sc_uicalc.mk index e0df316fe3ab..e3ab3387ddd2 100644 --- a/sc/CppunitTest_sc_uicalc.mk +++ b/sc/CppunitTest_sc_uicalc.mk @@ -9,7 +9,10 @@ $(eval $(call gb_CppunitTest_CppunitTest,sc_uicalc)) -$(eval $(call gb_CppunitTest_use_external,sc_uicalc,boost_headers)) +$(eval $(call gb_CppunitTest_use_externals,sc_uicalc, \ + boost_headers \ + mdds_headers \ +)) $(eval $(call gb_CppunitTest_add_exception_objects,sc_uicalc, \ sc/qa/unit/uicalc/uicalc \ diff --git a/sc/qa/unit/uicalc/data/tdf149503.xls b/sc/qa/unit/uicalc/data/tdf149503.xls Binary files differnew file mode 100644 index 000000000000..88e4fb4ad651 --- /dev/null +++ b/sc/qa/unit/uicalc/data/tdf149503.xls diff --git a/sc/qa/unit/uicalc/uicalc.cxx b/sc/qa/unit/uicalc/uicalc.cxx index 32981fb3a0fe..a6f648ce9766 100644 --- a/sc/qa/unit/uicalc/uicalc.cxx +++ b/sc/qa/unit/uicalc/uicalc.cxx @@ -29,6 +29,7 @@ #include <document.hxx> #include <docuno.hxx> #include <docsh.hxx> +#include <dpobject.hxx> #include <drwlayer.hxx> #include <inputopt.hxx> #include <postit.hxx> @@ -1511,6 +1512,26 @@ CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf86166) CPPUNIT_ASSERT_EQUAL(static_cast<SCTAB>(1), pDoc->GetTableCount()); } +CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf149503) +{ + ScModelObj* pModelObj = createDoc("tdf149503.xls"); + ScDocument* pDoc = pModelObj->GetDocument(); + CPPUNIT_ASSERT(pDoc); + + dispatchCommand(mxComponent, ".uno:SelectAll", {}); + Scheduler::ProcessEventsToIdle(); + + dispatchCommand(mxComponent, ".uno:Cut", {}); + Scheduler::ProcessEventsToIdle(); + + // Without the fix in place, this test would have crashed here + dispatchCommand(mxComponent, ".uno:Paste", {}); + Scheduler::ProcessEventsToIdle(); + + ScDPCollection* pDPs = pDoc->GetDPCollection(); + CPPUNIT_ASSERT_EQUAL(size_t(1), pDPs->GetCount()); +} + CPPUNIT_TEST_FIXTURE(ScUiCalcTest, testTdf108292) { ScModelObj* pModelObj = createDoc("tdf108292.ods"); diff --git a/sc/source/core/data/dpoutput.cxx b/sc/source/core/data/dpoutput.cxx index cf08913ac502..bf2109b300a3 100644 --- a/sc/source/core/data/dpoutput.cxx +++ b/sc/source/core/data/dpoutput.cxx @@ -1331,6 +1331,8 @@ void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionDa if (nField < 0) break; + if (pColFields.size() < o3tl::make_unsigned(nField) + 1 ) + break; const uno::Sequence<sheet::MemberResult> rSequence = pColFields[nField].maResult; if (!rSequence.hasElements()) break; @@ -1360,6 +1362,8 @@ void ScDPOutput::GetPositionData(const ScAddress& rPos, DataPilotTablePositionDa if (nField < 0) break; + if (pRowFields.size() < o3tl::make_unsigned(nField) + 1 ) + break; const uno::Sequence<sheet::MemberResult> rSequence = pRowFields[nField].maResult; if (!rSequence.hasElements()) break; |