Kaydet (Commit) 79f1ef44 authored tarafından Kohei Yoshida's avatar Kohei Yoshida

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
üst c1f9efa4
...@@ -1548,6 +1548,16 @@ void Test::testMatrix() ...@@ -1548,6 +1548,16 @@ void Test::testMatrix()
pMat->PutString(aStr, 8, 2); pMat->PutString(aStr, 8, 2);
pMat->PutEmptyPath(8, 11); pMat->PutEmptyPath(8, 11);
checkMatrixElements<PartiallyFilledEmptyMatrix>(*pMat); 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() void Test::testEnterMixedMatrix()
......
...@@ -418,11 +418,13 @@ bool ScMatrixImpl::IsImmutable() const ...@@ -418,11 +418,13 @@ bool ScMatrixImpl::IsImmutable() const
void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR) void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR)
{ {
maMat.resize(nR, nC); maMat.resize(nR, nC);
maMatFlag.resize(nR, nC);
} }
void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR, double fVal) void ScMatrixImpl::Resize(SCSIZE nC, SCSIZE nR, double fVal)
{ {
maMat.resize(nR, nC, fVal); maMat.resize(nR, nC, fVal);
maMatFlag.resize(nR, nC);
} }
void ScMatrixImpl::SetErrorInterpreter( ScInterpreter* p) void ScMatrixImpl::SetErrorInterpreter( ScInterpreter* p)
......
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