We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 52924e9 commit 94fcf92Copy full SHA for 94fcf92
src/dogroups.c
@@ -535,7 +535,12 @@ SEXP growVector(SEXP x, const R_len_t newlen)
535
if (isNull(x)) error(_("growVector passed NULL"));
536
PROTECT(newx = allocVector(TYPEOF(x), newlen)); // TO DO: R_realloc(?) here?
537
if (newlen < len) len=newlen; // i.e. shrink
538
- if (len) switch (TYPEOF(x)) {
+ if (!len) { // cannot memcpy invalid pointer, #6819
539
+ keepattr(newx, x)
540
+ UNPROTECT(1);
541
+ return newx;
542
+ }
543
+ switch (TYPEOF(x)) {
544
case RAWSXP: memcpy(RAW(newx), RAW(x), len*SIZEOF(x)); break;
545
case LGLSXP: memcpy(LOGICAL(newx), LOGICAL(x), len*SIZEOF(x)); break;
546
case INTSXP: memcpy(INTEGER(newx), INTEGER(x), len*SIZEOF(x)); break;
0 commit comments