Skip to content

Commit 5d5214c

Browse files
authored
Fix #190 (#191)
1 parent 47df07c commit 5d5214c

File tree

3 files changed

+18
-1
lines changed

3 files changed

+18
-1
lines changed

DESCRIPTION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: readODS
22
Type: Package
33
Title: Read and Write ODS Files
4-
Version: 2.3.0
4+
Version: 2.3.1
55
Authors@R:
66
c(person("Gerrit-Jan", "Schutten", role = c("aut"), email = "phonixor@gmail.com"),
77
person("Chung-hong", "Chan", role = c("aut", "cre"), email = "chainsawtiney@gmail.com", comment = c(ORCID = "0000-0002-6232-7530")),

NEWS.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# readODS 2.3.1
2+
3+
## Bug fixes
4+
5+
* Fix #190 a potential GC issue in the vendored cpp11 code, detected by rchk
6+
17
# readODS 2.3.0
28

39
* Use `minty` instead of `readr` to reduce the number of dependencies

inst/include/cpp11/r_vector.hpp

+11
Original file line numberDiff line numberDiff line change
@@ -918,12 +918,23 @@ inline r_vector<T>::operator SEXP() const {
918918
}
919919
if (length_ < capacity_) {
920920
p->data_ = truncate(p->data_, length_, capacity_);
921+
#if R_VERSION >= R_Version(3, 4, 0) && R_VERSION < R_Version(4, 5, 0)
921922
SEXP nms = names();
922923
auto nms_size = Rf_xlength(nms);
923924
if ((nms_size > 0) && (length_ < nms_size)) {
924925
nms = truncate(nms, length_, capacity_);
925926
names() = nms;
926927
}
928+
#else
929+
SEXP nms;
930+
PROTECT(nms = names());
931+
auto nms_size = Rf_xlength(nms);
932+
if ((nms_size > 0) && (length_ < nms_size)) {
933+
nms = truncate(nms, length_, capacity_);
934+
names() = nms;
935+
}
936+
UNPROTECT(1);
937+
#endif
927938
}
928939
return data_;
929940
}

0 commit comments

Comments
 (0)