Skip to content

Commit e26cfb3

Browse files
make rchk happy (#7520)
Co-authored-by: Michael Chirico <chiricom@google.com>
1 parent 3acb570 commit e26cfb3

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/subset.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ SEXP subsetDT(SEXP x, SEXP rows, SEXP cols) { // API change needs update NEWS.md
331331
SEXP tmp = PROTECT(R_allocResizableVector(STRSXP, LENGTH(cols)+overAlloc)); nprotect++;
332332
R_resizeVector(tmp, LENGTH(cols));
333333
setAttrib(ans, R_NamesSymbol, tmp);
334-
subsetVectorRaw(tmp, getAttrib(x, R_NamesSymbol), cols, /*anyNA=*/false);
334+
subsetVectorRaw(tmp, PROTECT(getAttrib(x, R_NamesSymbol)), cols, /*anyNA=*/false); nprotect++;
335335

336336
tmp = PROTECT(allocVector(INTSXP, 2)); nprotect++;
337337
INTEGER(tmp)[0] = NA_INTEGER;
@@ -341,7 +341,7 @@ SEXP subsetDT(SEXP x, SEXP rows, SEXP cols) { // API change needs update NEWS.md
341341
// clear any index that was copied over by copyMostAttrib() above, e.g. #1760 and #1734 (test 1678)
342342
setAttrib(ans, sym_index, R_NilValue);
343343
// but maintain key if ordered subset
344-
SEXP key = getAttrib(x, sym_sorted);
344+
SEXP key = PROTECT(getAttrib(x, sym_sorted)); nprotect++;
345345
if (length(key)) {
346346
SEXP innames = PROTECT(getAttrib(ans,R_NamesSymbol)); nprotect++;
347347
SEXP in = PROTECT(chin(key, innames)); nprotect++;
@@ -352,7 +352,7 @@ SEXP subsetDT(SEXP x, SEXP rows, SEXP cols) { // API change needs update NEWS.md
352352
setAttrib(ans, sym_sorted, R_NilValue);
353353
} else {
354354
// make a new key attribute; shorter if i<LENGTH(key) or same length copied so this key is safe to change by ref (setnames)
355-
setAttrib(ans, sym_sorted, tmp=allocVector(STRSXP, i));
355+
setAttrib(ans, sym_sorted, tmp=PROTECT(allocVector(STRSXP, i))); nprotect++;
356356
for (int j=0; j<i; j++) SET_STRING_ELT(tmp, j, STRING_ELT(key, j));
357357
}
358358
}

0 commit comments

Comments
 (0)