Skip to content

Commit da4b705

Browse files
committed
protect Rf_mkString inside Rf_lang3 and Rf_lang4
1 parent dd7b0d2 commit da4b705

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
* inst/include/Rcpp/Reference.h: Shield Rf_mkstring inside Rf_lang2
66
* inst/include/Rcpp/Environment.h: Idem (inside Rf_lang4)
7+
* inst/include/Rcpp/proxy/FieldProxy.h: Idem (inside Rf_lang3 and 4)
8+
79
2019-10-31 Romain Francois <[email protected]>
810

911
* inst/include/Rcpp/DataFrame.h: Protect temporaries from gc

inst/include/Rcpp/proxy/FieldProxy.h

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,14 @@ class FieldProxyPolicy {
4141
const std::string& field_name ;
4242

4343
SEXP get() const {
44-
Shield<SEXP> call( Rf_lang3( R_DollarSymbol, parent, Rf_mkString(field_name.c_str()) ) ) ;
44+
Shield<SEXP> str(Rf_mkString(field_name.c_str()));
45+
Shield<SEXP> call(Rf_lang3(R_DollarSymbol, parent, str));
4546
return Rcpp_fast_eval( call, R_GlobalEnv ) ;
4647
}
4748
void set(SEXP x ) {
4849
SEXP dollarGetsSym = Rf_install( "$<-");
49-
Shield<SEXP> call( Rf_lang4( dollarGetsSym, parent, Rf_mkString(field_name.c_str()) , x ) ) ;
50+
Shield<SEXP> str(Rf_mkString(field_name.c_str()));
51+
Shield<SEXP> call(Rf_lang4(dollarGetsSym, parent, str, x));
5052
parent.set__( Rcpp_fast_eval( call, R_GlobalEnv ) );
5153
}
5254
} ;
@@ -66,7 +68,8 @@ class FieldProxyPolicy {
6668
const std::string& field_name ;
6769

6870
SEXP get() const {
69-
Shield<SEXP> call( Rf_lang3( R_DollarSymbol, parent, Rf_mkString(field_name.c_str()) ) ) ;
71+
Shield<SEXP> str(Rf_mkString(field_name.c_str()));
72+
Shield<SEXP> call(Rf_lang3(R_DollarSymbol, parent, str));
7073
return Rcpp_fast_eval( call, R_GlobalEnv ) ;
7174
}
7275
} ;

0 commit comments

Comments
 (0)