Skip to content

Commit 732856e

Browse files
committed
Protect any calls constructed by Rf_lang
1 parent 3cd99b3 commit 732856e

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

inst/include/Rcpp/Module.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,9 @@ static VARIABLE_IS_NOT_USED SEXP moduleSym = NULL;
447447
#define GET_MODULE_SYM ( moduleSym == NULL ? moduleSym = Rf_install("Module") : moduleSym )
448448

449449
// this macro is called by code wanting to load a module -- see RInside's rinside_module_sample0.cpp
450-
#define LOAD_RCPP_MODULE(NAME) Rf_eval( Rf_lang2( GET_MODULE_SYM, _rcpp_module_boot_##NAME() ), R_GlobalEnv )
450+
#define LOAD_RCPP_MODULE(NAME) \
451+
Shield<SEXP> __load_module_call__( Rf_lang2( GET_MODULE_SYM, _rcpp_module_boot_##NAME() ); \
452+
Rf_eval(__load_module_call__), R_GlobalEnv );
451453

452454
#endif
453455

src/barrier.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,8 @@ SEXP get_rcpp_cache() {
9494

9595
SEXP getNamespaceSym = Rf_install("getNamespace"); // cannot be gc()'ed once in symbol table
9696
Rcpp::Shield<SEXP> RcppString( Rf_mkString("Rcpp") );
97-
Rcpp::Shield<SEXP> RCPP( Rf_eval(Rf_lang2( getNamespaceSym, RcppString ), R_GlobalEnv) ) ;
97+
Rcpp::Shield<SEXP> call( Rf_lang2( getNamespaceSym, RcppString ) );
98+
Rcpp::Shield<SEXP> RCPP( Rf_eval(call, R_GlobalEnv) ) ;
9899

99100
Rcpp_cache = Rf_findVarInFrame( RCPP, Rf_install(".rcpp_cache") ) ;
100101
Rcpp_cache_know = true ;

0 commit comments

Comments
 (0)