Skip to content

Commit

Permalink
Closes #1082. Fixed segfault in assignment by reference.
Browse files Browse the repository at this point in the history
  • Loading branch information
arunsrinivasan committed Mar 16, 2015
1 parent 1509253 commit b50163e
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@

45. Fixed another segfault in `melt.data.table` issue that was caught due to issue in Windows. Closes [#1059](https://github.com/Rdatatable/data.table/issues/1059). Thanks again to @ChristK for the minimal report.

46. `DT[rows, newcol := NULL]` resulted in a segfault on the next assignment by reference. Closes [#1082](https://github.com/Rdatatable/data.table/issues/1082). Thanks to @stevenbagley for the MRE.

#### NOTES

1. Clearer explanation of what `duplicated()` does (borrowed from base). Thanks to @matthieugomez for pointing out. Closes [#872](https://github.com/Rdatatable/data.table/issues/872).
Expand Down
7 changes: 7 additions & 0 deletions inst/tests/tests.Rraw
Original file line number Diff line number Diff line change
Expand Up @@ -6196,6 +6196,13 @@ ans2 <- cbind(ans21, ans22[, -1L])
setkey(setnames(setDT(ans2), names(ans1)), x)
test(1501.8, ans1, ans2)

# fix for #1082
dt1 = data.table(x=rep(c("a","b","c"),each=3), y=c(1,3,6), v=1:9, key=c("x", "y"))
dt2 = copy(dt1)
test(1502.1, dt1["a", z := NULL], error="When deleting columns, i should not be provided")
# this shouldn't segfault on 'dt1[...]'
test(1502.2, dt1["a", z := 42L], dt2["a", z := 42L])

##########################


Expand Down
2 changes: 2 additions & 0 deletions src/assign.c
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,8 @@ SEXP assign(SEXP dt, SEXP rows, SEXP cols, SEXP newcolnames, SEXP values, SEXP v
if (newcolnum<0 || newcolnum>=length(newcolnames))
error("Internal logical error. length(newcolnames)=%d, length(names)=%d, coln=%d", length(newcolnames), length(names), coln);
if (isNull(thisvalue)) {
// fix for #1082
if (!isNull(rows)) error("When deleting columns, i should not be provided");
warning("Adding new column '%s' then assigning NULL (deleting it).",CHAR(STRING_ELT(newcolnames,newcolnum)));
continue;
}
Expand Down

0 comments on commit b50163e

Please sign in to comment.