Skip to content

Commit

Permalink
Use snprintf instead of sprintf (even in trivial case)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddelbuettel committed Oct 25, 2022
1 parent 4015d89 commit b3b9bd9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2022-10-25 Dirk Eddelbuettel <edd@debian.org>

* inst/include/Rcpp/internal/r_coerce.h (coerce_to_string<RAWSXP >):
Replace last remaining sprintf with snprintf

2022-10-12 Dirk Eddelbuettel <edd@debian.org>

* DESCRIPTION (Version, Date): Roll minor version
Expand Down
4 changes: 2 additions & 2 deletions inst/include/Rcpp/internal/r_coerce.h
Original file line number Diff line number Diff line change
Expand Up @@ -246,13 +246,13 @@ inline const char* coerce_to_string<REALSXP>(double x){
template <>
inline const char* coerce_to_string<INTSXP >(int from) {
static char buffer[NB] ;
snprintf( buffer, NB, "%*d", integer_width(from), from );
snprintf(buffer, NB - 1, "%*d", integer_width(from), from);
return buffer ;
}
template <>
inline const char* coerce_to_string<RAWSXP >(Rbyte from){
static char buff[3];
::sprintf(buff, "%02x", from);
snprintf(buff, 2, "%02x", from);
return buff ;
}
template <>
Expand Down

0 comments on commit b3b9bd9

Please sign in to comment.