diff options
author | Kohei Yoshida <kyoshida@novell.com> | 2011-06-07 14:54:43 -0400 |
---|---|---|
committer | Kohei Yoshida <kyoshida@novell.com> | 2011-06-07 14:56:58 -0400 |
commit | 404b564149236a8ce2384306a7a34cf23fa5e0f6 (patch) | |
tree | 852cf2b0b76472ff66ff0208fc74e7a72408093e /sc | |
parent | 3c0cbc029db7d5b2989ac93086d0ca639b2f9cb0 (diff) |
Fixed out-of-bound access to array, which would cause a crash later.
And the crash was caused in a not-so-obvious way that it was near
impossible to link it to the cause. I had to resort to full inspection
of how the array was accessed in various methods.
Diffstat (limited to 'sc')
-rw-r--r-- | sc/source/ui/inc/viewdata.hxx | 1 | ||||
-rw-r--r-- | sc/source/ui/view/viewdata.cxx | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/sc/source/ui/inc/viewdata.hxx b/sc/source/ui/inc/viewdata.hxx index e4e5ddd9d384..4f7b03ac0d1a 100644 --- a/sc/source/ui/inc/viewdata.hxx +++ b/sc/source/ui/inc/viewdata.hxx @@ -236,6 +236,7 @@ private: SC_DLLPRIVATE void CreateTabData( SCTAB nNewTab ); SC_DLLPRIVATE void CreateTabData( std::vector< SCTAB >& rvTabs ); SC_DLLPRIVATE void CreateSelectedTabData(); + SC_DLLPRIVATE void EnsureTabDataSize(size_t nSize); public: ScViewData( ScDocShell* pDocSh, ScTabViewShell* pViewSh ); diff --git a/sc/source/ui/view/viewdata.cxx b/sc/source/ui/view/viewdata.cxx index 00b9874e60c3..f1fa41b6ca34 100644 --- a/sc/source/ui/view/viewdata.cxx +++ b/sc/source/ui/view/viewdata.cxx @@ -1450,6 +1450,15 @@ void ScViewData::CreateSelectedTabData() CreateTabData( i ); } +void ScViewData::EnsureTabDataSize(size_t nSize) +{ + if (nSize >= maTabData.size()) + { + size_t n = nSize - maTabData.size() + 1; + maTabData.insert(maTabData.end(), n, NULL); + } +} + void ScViewData::SetTabNo( SCTAB nNewTab ) { if (!ValidTab(nNewTab)) @@ -2758,7 +2767,10 @@ void ScViewData::ReadUserDataSequence(const uno::Sequence <beans::PropertyValue> uno::Sequence<beans::PropertyValue> aTabSettings; if (aAny >>= aTabSettings) { - maTabData[nTab] = new ScViewDataTable; + EnsureTabDataSize(nTab + 1); + if (!maTabData[nTab]) + maTabData[nTab] = new ScViewDataTable; + bool bHasZoom = false; maTabData[nTab]->ReadUserDataSequence(aTabSettings, *this, nTab, bHasZoom); aHasZoomVect[nTab] = bHasZoom; |