@@ -87,7 +87,8 @@ namespace Rcpp{
8787 T::ColsAtCompileTime>,
8888 const T&>::type objCopy (obj);
8989 int m = obj.rows (), n = obj.cols ();
90- SEXP ans = PROTECT (::Rcpp::wrap (objCopy.data (), objCopy.data () + m * n));
90+ R_xlen_t size = static_cast <R_xlen_t>(m) * n;
91+ SEXP ans = PROTECT (::Rcpp::wrap (objCopy.data (), objCopy.data () + size));
9192 if ( T::ColsAtCompileTime != 1 ) {
9293 SEXP dd = PROTECT (::Rf_allocVector (INTSXP, 2 ));
9394 int *d = INTEGER (dd);
@@ -159,7 +160,7 @@ namespace Rcpp{
159160 template <typename T, int RTYPE>
160161 class Eigen_Matrix_Exporter {
161162 public:
162- Eigen_Matrix_Exporter (SEXP x) : vec(x), d_ncol(1 ), d_nrow(Rf_length (x)) {
163+ Eigen_Matrix_Exporter (SEXP x) : vec(x), d_ncol(1 ), d_nrow(Rf_xlength (x)) {
163164 if (TYPEOF (x) != RTYPE)
164165 throw std::invalid_argument (" Wrong R type for mapped vector" );
165166 if (::Rf_isMatrix (x)) {
@@ -254,7 +255,7 @@ namespace Rcpp{
254255 int d_ncol, d_nrow ;
255256
256257 public:
257- Exporter (SEXP x) : vec(x), d_ncol(1 ), d_nrow(Rf_length (x)) {
258+ Exporter (SEXP x) : vec(x), d_ncol(1 ), d_nrow(Rf_xlength (x)) {
258259 if (TYPEOF (x) != RTYPE)
259260 throw std::invalid_argument (" Wrong R type for mapped matrix" );
260261 if (::Rf_isMatrix (x)) {
@@ -274,7 +275,7 @@ namespace Rcpp{
274275 int d_ncol, d_nrow ;
275276
276277 public:
277- Exporter (SEXP x) : vec(x), d_ncol(1 ), d_nrow(Rf_length (x)) {
278+ Exporter (SEXP x) : vec(x), d_ncol(1 ), d_nrow(Rf_xlength (x)) {
278279 if (TYPEOF (x) != RTYPE)
279280 throw std::invalid_argument (" Wrong R type for mapped 2D array" );
280281 if (::Rf_isMatrix (x)) {
0 commit comments