Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions matlab.h
Original file line number Diff line number Diff line change
Expand Up @@ -436,8 +436,10 @@ MatrixView unwrapMatrixView(const mxArray* array) {
if (mxIsDouble(array)==false || mxIsComplex(array) || mxIsSparse(array))
error("unwrapMatrixView: not a full real double matrix");
const mwSize rows = mxGetM(array), cols = mxGetN(array);
if (rows > static_cast<mwSize>(std::numeric_limits<Eigen::Index>::max()) ||
cols > static_cast<mwSize>(std::numeric_limits<Eigen::Index>::max())) {
const auto maxIndex =
static_cast<unsigned long long>((std::numeric_limits<Eigen::Index>::max)());
if (static_cast<unsigned long long>(rows) > maxIndex ||
static_cast<unsigned long long>(cols) > maxIndex) {
error("unwrapMatrixView: matrix dimensions exceed Eigen::Index");
}
const Eigen::Index m = static_cast<Eigen::Index>(rows);
Expand Down
1 change: 1 addition & 0 deletions tests/test_matlab_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ def test_matrix_view_arguments(self):
self.assertIn('unwrapMatrixView', header_content)
self.assertIn('mxIsSparse(array)', header_content)
self.assertIn('mwSize rows', header_content)
self.assertIn('static_cast<unsigned long long>(rows)', header_content)
self.assertIn('Eigen::Index m', header_content)
self.assertIn('Stride(m, 1)', header_content)

Expand Down
Loading