Skip to content

Commit ffe75b2

Browse files
very conservative about getAttrib()?
1 parent 1aeb6ae commit ffe75b2

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/assign.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ SEXP setdt_nrows(SEXP x)
219219
if (Rf_inherits(xi, "POSIXlt")) {
220220
error(_("Column %d has class 'POSIXlt'. Please convert it to POSIXct (using as.POSIXct) and run setDT() again. We do not recommend the use of POSIXlt at all because it uses 40 bytes to store one date."), i+1);
221221
}
222-
SEXP dim_xi = getAttrib(xi, R_DimSymbol);
222+
SEXP dim_xi = PROTECT(getAttrib(xi, R_DimSymbol));
223223
R_len_t len_xi;
224224
// NB: LENGTH() produces an undefined large number here on R 3.3.0.
225225
// There's also a note in NEWS for R 3.1.0 saying length() should always be used by packages,
@@ -234,6 +234,7 @@ SEXP setdt_nrows(SEXP x)
234234
} else {
235235
len_xi = LENGTH(xi);
236236
}
237+
UNPROTECT(1);
237238
if (!base_length) {
238239
base_length = len_xi;
239240
} else if (len_xi != base_length) {

0 commit comments

Comments
 (0)