Skip to content

Commit 52bfbac

Browse files
committed
Use snprintf instead of sprintf (even in trivial case)
1 parent 198ecb3 commit 52bfbac

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
* inst/tinytest/cpp/coerce.cpp: add coerce unit tests
44
* inst/tinytest/test_coerce.R: idem
55

6+
2022-10-25 Dirk Eddelbuettel <[email protected]>
7+
8+
* inst/include/Rcpp/internal/r_coerce.h (coerce_to_string<RAWSXP >):
9+
Replace last remaining sprintf with snprintf
10+
611
2022-10-12 Dirk Eddelbuettel <[email protected]>
712

813
* DESCRIPTION (Version, Date): Roll minor version

inst/include/Rcpp/internal/r_coerce.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -246,14 +246,14 @@ inline const char* coerce_to_string<REALSXP>(double x){
246246
template <>
247247
inline const char* coerce_to_string<INTSXP >(int from) {
248248
static char buffer[NB] ;
249-
snprintf( buffer, NB, "%*d", integer_width(from), from );
249+
snprintf(buffer, NB, "%*d", integer_width(from), from);
250250
return buffer ;
251251
}
252252
template <>
253253
inline const char* coerce_to_string<RAWSXP >(Rbyte from){
254254
static char buff[3];
255-
::sprintf(buff, "%02x", from);
256-
return buff ;
255+
snprintf(buff, 3, "%02x", from);
256+
return buff;
257257
}
258258
template <>
259259
inline const char* coerce_to_string<LGLSXP >(int from){

0 commit comments

Comments
 (0)