diff options
author | Benoit Jacob <jacob.benoit.1@gmail.com> | 2011-10-16 16:12:19 -0400 |
---|---|---|
committer | Benoit Jacob <jacob.benoit.1@gmail.com> | 2011-10-16 16:12:19 -0400 |
commit | dcbc985a2821544f4d035e103494d34972ccf71f (patch) | |
tree | 31e7f3f974578663b5f5ab035c85395e967b636c /Eigen/src/Core/PlainObjectBase.h | |
parent | 739559b08a6dd6a169837ca166b6887f024e0c01 (diff) |
bug #363 - add test for integer overflow in size computations
Diffstat (limited to 'Eigen/src/Core/PlainObjectBase.h')
-rw-r--r-- | Eigen/src/Core/PlainObjectBase.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/Eigen/src/Core/PlainObjectBase.h b/Eigen/src/Core/PlainObjectBase.h index 84ef2b4da..11a465c4d 100644 --- a/Eigen/src/Core/PlainObjectBase.h +++ b/Eigen/src/Core/PlainObjectBase.h @@ -40,10 +40,10 @@ void check_rows_cols_for_overflow(Index rows, Index cols) #ifdef EIGEN_EXCEPTIONS // http://hg.mozilla.org/mozilla-central/file/6c8a909977d3/xpcom/ds/CheckedInt.h#l242 // we assume Index is signed - Index max_index = (Index(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed - bool error = (x < 0 || y < 0) ? true - : (x == 0 || y == 0) ? false - : (x > max_index / y); + Index max_index = (size_t(1) << (8 * sizeof(Index) - 1)) - 1; // assume Index is signed + bool error = (rows < 0 || cols < 0) ? true + : (rows == 0 || cols == 0) ? false + : (rows > max_index / cols); if (error) throw std::bad_alloc(); #else @@ -438,7 +438,7 @@ class PlainObjectBase : public internal::dense_xpr_base<Derived>::type : m_storage(other.derived().rows() * other.derived().cols(), other.derived().rows(), other.derived().cols()) { _check_template_params(); - internal::check_rows_cols_for_overflow((other.derived().rows(), other.derived().cols()); + internal::check_rows_cols_for_overflow(other.derived().rows(), other.derived().cols()); Base::operator=(other.derived()); } |