Skip to content

Commit 4e7e927

Browse files
committed
fitInInt*: disallow integer64
Since the functions themselves read the vector as double* and are used as a test whether doubles from the vector would fit in an integer, avoid reading integer64 vectors altogether.
1 parent e201bb9 commit 4e7e927

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/utils.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ bool within_int64_repres(double x) {
1414
// used to error if not passed type double but this needed extra is.double() calls in calling R code
1515
// which needed a repeat of the argument. Hence simpler and more robust to return false when not type double.
1616
bool fitsInInt32(SEXP x) {
17-
if (!isReal(x))
17+
if (!isReal(x) || INHERITS(x, char_integer64))
1818
return false;
1919
R_xlen_t n=xlength(x), i=0;
2020
const double *dx = REAL(x);
@@ -31,7 +31,7 @@ SEXP fitsInInt32R(SEXP x) {
3131
}
3232

3333
bool fitsInInt64(SEXP x) {
34-
if (!isReal(x))
34+
if (!isReal(x) || INHERITS(x, char_integer64))
3535
return false;
3636
R_xlen_t n=xlength(x), i=0;
3737
const double *dx = REAL(x);

0 commit comments

Comments
 (0)