Skip to content

Commit

Permalink
Merge branch 'proctect' into cran-2.6-6
Browse files Browse the repository at this point in the history
  • Loading branch information
jarioksa committed May 21, 2024
2 parents aaca871 + 89f3629 commit f5eb6fc
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: vegan
Title: Community Ecology Package
Version: 2.6-6
Version: 2.6-6.1
Authors@R: c(person("Jari", "Oksanen", role=c("aut","cre"),
email="[email protected]"),
person("Gavin L.", "Simpson", role="aut",
Expand Down
6 changes: 6 additions & 0 deletions inst/NEWS.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
## vegan News

### Changes in version 2\.6-6\.1

* C function `do_wcentre` (weighted centring) can segfault due to a
protection error. The problem was found in automatic CRAN checks and
the fix was verified in Tomas Kalibera's docker container.

### Changes in version 2\.6-6

#### INSTALLATION
Expand Down
8 changes: 5 additions & 3 deletions src/goffactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,14 @@ SEXP do_wcentre(SEXP x, SEXP w)
error("weights 'w' and data do not match");
if (TYPEOF(x) != REALSXP)
x = coerceVector(x, REALSXP);
PROTECT(x);
SEXP rx = PROTECT(duplicate(x));
if (TYPEOF(w) != REALSXP)
w = coerceVector(w, REALSXP);
w = PROTECT(duplicate(w));
PROTECT(w);
SEXP rw = PROTECT(duplicate(w));
SEXP retx = PROTECT(allocMatrix(REALSXP, nr, nc));
wcentre(REAL(rx), REAL(retx), REAL(w), &nr, &nc);
wcentre(REAL(rx), REAL(retx), REAL(rw), &nr, &nc);
/* set dimnames */
SEXP dnames = getAttrib(x, R_DimNamesSymbol);
if (!isNull(dnames)) {
Expand All @@ -93,7 +95,7 @@ SEXP do_wcentre(SEXP x, SEXP w)
setAttrib(retx, R_DimNamesSymbol, dimnames);
UNPROTECT(1);
}
UNPROTECT(3);
UNPROTECT(5);
return retx;
}

Expand Down

0 comments on commit f5eb6fc

Please sign in to comment.