Skip to content

Commit 40191d7

Browse files
appease the rchk gods
1 parent 71bb8b1 commit 40191d7

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

src/mergelist.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -65,15 +65,15 @@ SEXP cbindlist(SEXP x, SEXP copyArg) {
6565
}
6666
if (recycle)
6767
error("Rows recycling for objects of different nrow is not yet implemented"); // dont we have a routines for that already somewhere?
68-
int protecti=0;
69-
SEXP ans = PROTECT(allocVector(VECSXP, nans)); protecti++;
70-
SEXP index = PROTECT(allocVector(INTSXP, 0)); protecti++;
68+
SEXP ans = PROTECT(allocVector(VECSXP, nans));
69+
SEXP index = PROTECT(allocVector(INTSXP, 0));
7170
SEXP key = R_NilValue;
7271
setAttrib(ans, sym_index, index);
73-
SEXP names = PROTECT(allocVector(STRSXP, nans)); protecti++;
72+
SEXP names = PROTECT(allocVector(STRSXP, nans));
7473
for (int i=0, ians=0; i<nx; ++i) {
74+
int protect i =0;
7575
SEXP thisx = VECTOR_ELT(x, i);
76-
SEXP thisnames = getAttrib(thisx, R_NamesSymbol);
76+
SEXP thisnames = PROTECT(getAttrib(thisx, R_NamesSymbol)); protecti++
7777
for (int j=0; j<nnx[i]; ++j, ++ians) {
7878
SEXP thisxcol;
7979
if (copy) {
@@ -87,11 +87,12 @@ SEXP cbindlist(SEXP x, SEXP copyArg) {
8787
mergeIndexAttrib(index, getAttrib(thisx, sym_index));
8888
if (isNull(key)) // first key is retained
8989
key = getAttrib(thisx, sym_sorted);
90+
UNPROTECT(protecti);
9091
}
9192
setAttrib(ans, R_NamesSymbol, names);
9293
setAttrib(ans, sym_sorted, key);
9394
if (verbose)
9495
Rprintf("cbindlist: took %.3fs\n", omp_get_wtime()-tic);
95-
UNPROTECT(protecti);
96+
UNPROTECT(3);
9697
return ans;
9798
}

0 commit comments

Comments
 (0)