Kaydet (Commit) 404b5641 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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.
üst 3c0cbc02
......@@ -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 );
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment