Skip to content

Commit b99f5aa

Browse files
author
Qiang Kou
committed
fix overflow in matrix column
1 parent d97b13e commit b99f5aa

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

inst/include/Rcpp/vector/MatrixColumn.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,16 +36,16 @@ class MatrixColumn : public VectorBase<RTYPE,true,MatrixColumn<RTYPE> > {
3636

3737
MatrixColumn( MATRIX& parent, int i ) :
3838
n(parent.nrow()),
39-
start(parent.begin() + i * n ),
40-
const_start(const_cast<const MATRIX&>(parent).begin() + i *n)
39+
start(parent.begin() + static_cast<R_xlen_t>(i) * n ),
40+
const_start(const_cast<const MATRIX&>(parent).begin() + static_cast<R_xlen_t>(i) * n)
4141
{
4242
if( i < 0 || i >= parent.ncol() ) throw index_out_of_bounds() ;
4343
}
4444

4545
MatrixColumn( const MATRIX& parent, int i ) :
4646
n(parent.nrow()),
47-
start( const_cast<MATRIX&>(parent).begin() + i * n ),
48-
const_start(parent.begin() + i *n)
47+
start( const_cast<MATRIX&>(parent).begin() + static_cast<R_xlen_t>(i) * n ),
48+
const_start(parent.begin() + static_cast<R_xlen_t>(i) * n)
4949
{
5050
if( i < 0 || i >= parent.ncol() ) throw index_out_of_bounds() ;
5151
}

0 commit comments

Comments
 (0)