Skip to content

Commit f1325f9

Browse files
committed
Attempt to fix rchk issue related to names
1 parent dc93fb8 commit f1325f9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

NEWS.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# cpp11 (development version)
22

3+
* Fixed a small protection issue flagged by rchk (#408).
4+
35
# cpp11 0.5.0
46

57
## R non-API related changes

inst/include/cpp11/r_vector.hpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -1323,7 +1323,8 @@ inline SEXP r_vector<T>::reserve_data(SEXP x, bool is_altrep, R_xlen_t size) {
13231323
SEXP out = PROTECT(resize_data(x, is_altrep, size));
13241324

13251325
// Resize names, if required
1326-
SEXP names = Rf_getAttrib(x, R_NamesSymbol);
1326+
// Protection seems needed to make rchk happy
1327+
SEXP names = PROTECT(Rf_getAttrib(x, R_NamesSymbol));
13271328
if (names != R_NilValue) {
13281329
if (Rf_xlength(names) != size) {
13291330
names = resize_names(names, size);
@@ -1338,7 +1339,7 @@ inline SEXP r_vector<T>::reserve_data(SEXP x, bool is_altrep, R_xlen_t size) {
13381339
// Does not look like it would ever error in our use cases, so no `safe[]`.
13391340
Rf_copyMostAttrib(x, out);
13401341

1341-
UNPROTECT(1);
1342+
UNPROTECT(2);
13421343
return out;
13431344
}
13441345

0 commit comments

Comments
 (0)