diff options
author | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-01-02 15:49:24 -0500 |
---|---|---|
committer | Kohei Yoshida <kohei.yoshida@gmail.com> | 2013-01-02 20:54:36 -0500 |
commit | 30285360e5d1fbb14bb6bf54e55a3a9f9b7619e7 (patch) | |
tree | 6c3263f629a4f333cb7b444c2f420c821169d2ab | |
parent | e2b91f39f7162e031c07235a60bfe04f26fee53a (diff) |
fdo#58539: Resizing matrix should also resize the flag storage too.
Or else resizing and then putting empty elements may crash. The flag
storage is used only for empty elements.
Change-Id: I1ada8f795a01336af185e6180bc03247c44472ba
-rw-r--r-- | sc/qa/unit/ucalc.cxx | 10 | ||||
-rw-r--r-- | sc/source/core/tool/scmatrix.cxx | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/sc/qa/unit/ucalc.cxx b/sc/qa/unit/ucalc.cxx index 4b7e4fd5c1eb..6a8af5de996b 100644 --- a/sc/qa/unit/ucalc.cxx +++ b/sc/qa/unit/ucalc.cxx @@ -1548,6 +1548,16 @@ void Test::testMatrix() pMat->PutString(aStr, 8, 2); pMat->PutEmptyPath(8, 11); checkMatrixElements<PartiallyFilledEmptyMatrix>(*pMat); + + // Test resizing. + pMat = new ScMatrix(0, 0); + pMat->Resize(2, 2, 1.5); + pMat->PutEmpty(1, 1); + + CPPUNIT_ASSERT_EQUAL(1.5, pMat->GetDouble(0, 0)); + CPPUNIT_ASSERT_EQUAL(1.5, pMat->GetDouble(0, 1)); + CPPUNIT_ASSERT_EQUAL(1.5, pMat->GetDouble(1, 0)); + CPPUNIT_ASSERT_MESSAGE("PutEmpty() call failed.", pMat->IsEmpty(1, 1)); } void Test::testEnterMixedMatrix() diff --git a/sc/source/core/tool/scmatrix.cxx b/sc/source/core/tool/scmatrix.cxx index 66dcb2f83155..0a92ffc2721a 100644 --- a/sc/source/core/tool/scmatrix.cxx +++ b/sc/source/core/tool/scmatrix.cxx @@ -418,11 +418,13 @@ bool ScMatrixImpl::IsImmutable() const void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR) { maMat.resize(nR, nC); + maMatFlag.resize(nR, nC); } void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR, double fVal) { maMat.resize(nR, nC, fVal); + maMatFlag.resize(nR, nC); } void ScMatrixImpl::SetErrorInterpreter( ScInterpreter* p) |