mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Fix crash on construction of SparseMatrix with zero-length diagonal
libeigen/eigen!2249
This commit is contained in:
committed by
Charles Schlosser
parent
265496e862
commit
d8c8ee6fb2
@@ -1008,7 +1008,7 @@ class SparseMatrix : public SparseCompressedBase<SparseMatrix<Scalar_, Options_,
|
||||
|
||||
const bool overwrite = internal::is_same<Func, internal::assign_op<Scalar, Scalar>>::value;
|
||||
if (overwrite) {
|
||||
if ((m_outerSize != n) || (m_innerSize != n)) resize(n, n);
|
||||
if ((m_outerSize != n) || (m_innerSize != n) || (n == 0)) resize(n, n);
|
||||
}
|
||||
|
||||
if (m_data.size() == 0 || overwrite) {
|
||||
|
||||
@@ -871,6 +871,10 @@ void sparse_basic(const SparseMatrixType& ref) {
|
||||
m2 -= d.asDiagonal();
|
||||
refMat2 -= d.asDiagonal();
|
||||
VERIFY_IS_APPROX(m2, refMat2);
|
||||
|
||||
// zero-length diagonal
|
||||
d = DenseVector(0);
|
||||
SparseMatrixType m4(d.asDiagonal());
|
||||
}
|
||||
|
||||
// test conservative resize
|
||||
|
||||
Reference in New Issue
Block a user