From 5dda7842ca66c7a81b703734bc7bd8cef11a6d7b Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Tue, 26 Feb 2013 11:42:32 +0100 Subject: [PATCH] Add assertion on the input matrix size in factorizations relying on permutations of 32bits int --- Eigen/src/LU/FullPivLU.h | 3 +++ Eigen/src/LU/PartialPivLU.h | 3 +++ Eigen/src/QR/ColPivHouseholderQR.h | 3 +++ 3 files changed, 9 insertions(+) diff --git a/Eigen/src/LU/FullPivLU.h b/Eigen/src/LU/FullPivLU.h index 14a9c402d..dfe25f424 100644 --- a/Eigen/src/LU/FullPivLU.h +++ b/Eigen/src/LU/FullPivLU.h @@ -417,6 +417,9 @@ FullPivLU::FullPivLU(const MatrixType& matrix) template FullPivLU& FullPivLU::compute(const MatrixType& matrix) { + // the permutations are stored as int indices, so just to be sure: + eigen_assert(matrix.rows()<=NumTraits::highest() && matrix.cols()<=NumTraits::highest()); + m_isInitialized = true; m_lu = matrix; diff --git a/Eigen/src/LU/PartialPivLU.h b/Eigen/src/LU/PartialPivLU.h index c9ff9dd5a..4017b5699 100644 --- a/Eigen/src/LU/PartialPivLU.h +++ b/Eigen/src/LU/PartialPivLU.h @@ -386,6 +386,9 @@ void partial_lu_inplace(MatrixType& lu, TranspositionType& row_transpositions, t template PartialPivLU& PartialPivLU::compute(const MatrixType& matrix) { + // the row permutation is stored as int indices, so just to be sure: + eigen_assert(matrix.rows()::highest()); + m_lu = matrix; eigen_assert(matrix.rows() == matrix.cols() && "PartialPivLU is only for square (and moreover invertible) matrices"); diff --git a/Eigen/src/QR/ColPivHouseholderQR.h b/Eigen/src/QR/ColPivHouseholderQR.h index 2cb255652..9ec8a65e4 100644 --- a/Eigen/src/QR/ColPivHouseholderQR.h +++ b/Eigen/src/QR/ColPivHouseholderQR.h @@ -401,6 +401,9 @@ ColPivHouseholderQR& ColPivHouseholderQR::compute(const Index rows = matrix.rows(); Index cols = matrix.cols(); Index size = matrix.diagonalSize(); + + // the column permutation is stored as int indices, so just to be sure: + eigen_assert(cols<=NumTraits::highest()); m_qr = matrix; m_hCoeffs.resize(size);