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 15:51:23 -0500 |
commit | 79f1ef44e77074d8f5a1d32e0447118e5b9c4e70 (patch) | |
tree | 8681bd4a3023adcd02a55facdc5eae5164d5ceaf | |
parent | c1f9efa4ac8a406cf10f3b5585f45ee0114621e4 (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) |