[Rcpp-commits] r3411 - pkg/Rcpp/inst/include/Rcpp

noreply at r-forge.r-project.org noreply at r-forge.r-project.org
Fri Dec 16 19:34:51 CET 2011


Author: dmbates
Date: 2011-12-16 19:34:50 +0100 (Fri, 16 Dec 2011)
New Revision: 3411

Modified:
   pkg/Rcpp/inst/include/Rcpp/XPtr.h
Log:
When constructing an XPtr from an SEXP, check the type.


Modified: pkg/Rcpp/inst/include/Rcpp/XPtr.h
===================================================================
--- pkg/Rcpp/inst/include/Rcpp/XPtr.h	2011-12-14 00:40:31 UTC (rev 3410)
+++ pkg/Rcpp/inst/include/Rcpp/XPtr.h	2011-12-16 18:34:50 UTC (rev 3411)
@@ -57,6 +57,8 @@
      * @param xp external pointer to wrap
      */
     explicit XPtr(SEXP m_sexp, SEXP tag = R_NilValue, SEXP prot = R_NilValue) : RObject(m_sexp){
+	if( TYPEOF(m_sexp) != EXTPTRSXP )
+	    throw ::Rcpp::not_compatible( "expecting an external pointer" ) ;
     	R_SetExternalPtrTag( m_sexp, tag ) ;
     	R_SetExternalPtrProtected( m_sexp, prot ) ;
     } ;



More information about the Rcpp-commits mailing list