Skip to content

Commit

Permalink
PROTECT() more in forder+bmerge (#6324)
Browse files Browse the repository at this point in the history
  • Loading branch information
MichaelChirico authored Jul 29, 2024
1 parent 0a25b42 commit bb46efe
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/bmerge.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,11 @@ SEXP bmerge(SEXP idt, SEXP xdt, SEXP icolsArg, SEXP xcolsArg, SEXP xoArg, SEXP r
allGrp1[0] = TRUE;
protecti += 2;

SEXP oSxp = PROTECT(forderReuseSorting(idt, icolsArg, /* retGrpArg= */ScalarLogical(FALSE), /* retStatsArg= */ScalarLogical(FALSE), /* sortGroupsArg= */ScalarLogical(TRUE), /* ascArg= */ScalarInteger(1), /* naArg= */ScalarLogical(FALSE), /* lazyArg= */ScalarLogical(TRUE))); protecti++;
SEXP ascArg = PROTECT(ScalarInteger(1));
SEXP oSxp = PROTECT(forderReuseSorting(idt, icolsArg, /* retGrpArg= */ScalarLogical(FALSE), /* retStatsArg= */ScalarLogical(FALSE), /* sortGroupsArg= */ScalarLogical(TRUE), ascArg, /* naArg= */ScalarLogical(FALSE), /* lazyArg= */ScalarLogical(TRUE))); protecti++;
UNPROTECT(2); // down stack to 'ascArg'
PROTECT(oSxp);

if (!LENGTH(oSxp))
o = NULL;
else
Expand Down
4 changes: 3 additions & 1 deletion src/forder.c
Original file line number Diff line number Diff line change
Expand Up @@ -1540,10 +1540,12 @@ bool colsKeyHead(SEXP x, SEXP cols) {
SEXP idxName(SEXP x, SEXP cols) {
if (!isInteger(cols))
error("internal error: 'cols' must be an integer"); // # nocov
SEXP dt_names = getAttrib(x, R_NamesSymbol);
SEXP dt_names = PROTECT(getAttrib(x, R_NamesSymbol));
if (!isString(dt_names))
error("internal error: 'DT' has no names"); // # nocov
SEXP idx_names = PROTECT(subsetVector(dt_names, cols));
UNPROTECT(2); // down-stack to 'dt_names'
PROTECT(idx_names);
SEXP char_underscore2 = PROTECT(ScalarString(mkChar("__")));
SEXP char_empty = PROTECT(ScalarString(mkChar("")));
SEXP sym_paste0 = install("paste0");
Expand Down

0 comments on commit bb46efe

Please sign in to comment.