Skip to content

Commit b735942

Browse files
committed
Support matrix case
1 parent 3d5e62f commit b735942

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

inst/include/Rcpp/vector/no_init.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,11 @@ class no_init_matrix {
6262

6363
template <int RTYPE, template <class> class StoragePolicy >
6464
operator Matrix<RTYPE, StoragePolicy>() const {
65-
return Rf_allocMatrix(RTYPE, nr, nc);
65+
// Explicitly protect temporary matrix to avoid false positive
66+
// with rchk (#892)
67+
Shield<SEXP> x(Rf_allocMatrix(RTYPE, nr, nc));
68+
Matrix<RTYPE, PreserveStorage> ret(x);
69+
return ret;
6670
}
6771

6872
private:

0 commit comments

Comments
 (0)