Skip to content

Commit cb32c5c

Browse files
authored
Fix UB for non-integer RTYPEs in comparator (#1453)
1 parent 2d1468f commit cb32c5c

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2026-02-17 Iñaki Ucar <iucar@fedoraproject.org>
2+
3+
* inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h: Fix UB
4+
for non-integer RTYPEs in comparator
5+
16
2026-01-23 Dirk Eddelbuettel <edd@debian.org>
27

38
* inst/include/Rcpp/DataFrame.h (nrow): Use R_nrow() with R >= 4.6.0

inst/include/Rcpp/sugar/operators/Comparator_With_One_Value.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
//
33
// LessThan.h: Rcpp R/C++ interface class library -- vector operators
44
//
5-
// Copyright (C) 2010 - 2011 Dirk Eddelbuettel and Romain Francois
5+
// Copyright (C) 2010 - 2025 Dirk Eddelbuettel and Romain Francois
6+
// Copyright (C) 2026 Dirk Eddelbuettel, Romain Francois and Iñaki Ucar
67
//
78
// This file is part of Rcpp.
89
//
@@ -56,7 +57,7 @@ class Comparator_With_One_Value : public ::Rcpp::VectorBase< LGLSXP, true, Compa
5657
inline int rhs_is_na(int i) const { return rhs ; }
5758
inline int rhs_is_not_na(int i) const {
5859
STORAGE x = lhs[i] ;
59-
return Rcpp::traits::is_na<RTYPE>(x) ? x : op( x, rhs ) ;
60+
return Rcpp::traits::is_na<RTYPE>(x) ? NA_INTEGER : op( x, rhs ) ;
6061
}
6162

6263
} ;

0 commit comments

Comments
 (0)