Skip to content

Commit 4c4721a

Browse files
committed
Fix more false rchk positives
1 parent 5dbfca1 commit 4c4721a

File tree

4 files changed

+9
-5
lines changed

4 files changed

+9
-5
lines changed

inst/include/Rcpp/api/meat/Rcpp_eval.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ inline SEXP Rcpp_fast_eval(SEXP expr, SEXP env) {
7575
inline SEXP Rcpp_eval(SEXP expr, SEXP env) {
7676

7777
// 'identity' function used to capture errors, interrupts
78-
SEXP identity = Rf_findFun(::Rf_install("identity"), R_BaseNamespace);
78+
Shield<SEXP> identity(Rf_findFun(::Rf_install("identity"), R_BaseNamespace));
7979

8080
if (identity == R_UnboundValue) {
8181
stop("Failed to find 'base::identity()'");

inst/include/Rcpp/exceptions.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ namespace internal {
243243
inline bool is_Rcpp_eval_call(SEXP expr) {
244244
SEXP sys_calls_symbol = Rf_install("sys.calls");
245245
SEXP identity_symbol = Rf_install("identity");
246-
SEXP identity_fun = Rf_findFun(identity_symbol, R_BaseEnv);
246+
Shield<SEXP> identity_fun(Rf_findFun(identity_symbol, R_BaseEnv));
247247
SEXP tryCatch_symbol = Rf_install("tryCatch");
248248
SEXP evalq_symbol = Rf_install("evalq");
249249

inst/include/Rcpp/protection/Shelter.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@ namespace Rcpp {
2727

2828
inline SEXP operator()(SEXP x){
2929
nprotected++;
30-
return PROTECT(x) ;
30+
return Rcpp_protect(x) ;
3131
}
3232

3333
~Shelter(){
34-
UNPROTECT(nprotected) ;
34+
Rcpp_unprotect(nprotected) ;
3535
nprotected = 0 ;
3636
}
3737

inst/include/Rcpp/protection/Shield.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,16 @@ namespace Rcpp{
2525
return x ;
2626
}
2727

28+
inline SEXP Rcpp_unprotect(int i){
29+
UNPROTECT(i);
30+
}
31+
2832
template <typename T>
2933
class Shield{
3034
public:
3135
Shield( SEXP t_) : t(Rcpp_protect(t_)){}
3236
~Shield(){
33-
if( t != R_NilValue ) UNPROTECT(1) ;
37+
if( t != R_NilValue ) Rcpp_unprotect(1) ;
3438
}
3539

3640
operator SEXP() const { return t; }

0 commit comments

Comments
 (0)