diff --git a/NEWS.md b/NEWS.md index f0ddda29e5..046c6efc48 100644 --- a/NEWS.md +++ b/NEWS.md @@ -133,6 +133,8 @@ rowwiseDT( 19. An integer overflow in `fread()` with lines longer than `2^(31/2)` bytes is prevented, [#6729](https://github.com/Rdatatable/data.table/issues/6729). The typical impact was no worse than a wrong initial allocation size, corrected later. Thanks to @TaikiSan21 for the report and @aitap for the fix. +20. Fixed a memory issue causing segfaults in `forder`, [#6797](https://github.com/Rdatatable/data.table/issues/6797). Thanks @dkutner for the report and @MichaelChirico for the fix. + ## NOTES 1. There is a new vignette on joins! See `vignette("datatable-joins")`. Thanks to Angel Feliz for authoring it! Feedback welcome. This vignette has been highly requested since 2017: [#2181](https://github.com/Rdatatable/data.table/issues/2181). diff --git a/src/forder.c b/src/forder.c index b32215d1c6..a82854e228 100644 --- a/src/forder.c +++ b/src/forder.c @@ -488,11 +488,10 @@ SEXP forder(SEXP DT, SEXP by, SEXP retGrpArg, SEXP retStatsArg, SEXP sortGroupsA if (LENGTH(ascArg) != LENGTH(by)) { if (LENGTH(ascArg)!=1) STOP(_("'order' length (%d) is different to by='s length (%d)"), LENGTH(ascArg), LENGTH(by)); - SEXP recycleAscArg = PROTECT(allocVector(INTSXP, LENGTH(by))); + SEXP recycleAscArg = PROTECT(allocVector(INTSXP, LENGTH(by))); n_protect++; for (int j=0; j