diff --git a/ChangeLog b/ChangeLog index e1052630c..473f40b99 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2015-09-21 Dirk Eddelbuettel + + * inst/include/Rcpp/String.h: Before assigning ensure we received + exactly one string argument + 2015-09-10 Dirk Eddelbuettel * DESCRIPTION: Release 0.12.1 diff --git a/DESCRIPTION b/DESCRIPTION index 8def0b7d6..e057e02b2 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: Rcpp Title: Seamless R and C++ Integration -Version: 0.12.1 -Date: 2015-09-10 +Version: 0.12.1.1 +Date: 2015-09-21 Author: Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey, Qiang Kou, Douglas Bates and John Chambers Maintainer: Dirk Eddelbuettel diff --git a/inst/NEWS.Rd b/inst/NEWS.Rd index 9199882ed..0413e393b 100644 --- a/inst/NEWS.Rd +++ b/inst/NEWS.Rd @@ -2,6 +2,16 @@ \title{News for Package 'Rcpp'} \newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}} +\section{Changes in Rcpp version 0.12.2 (expected 2015-11-01 or later)}{ + \itemize{ + \item Changes in Rcpp API: + \itemize{ + \item Before creating a single String object from a \code{SEXP}, ensure + that it is from a vector of length one (issue #375) + } + } +} + \section{Changes in Rcpp version 0.12.1 (2015-09-10)}{ \itemize{ \item Changes in Rcpp API: diff --git a/inst/include/Rcpp/String.h b/inst/include/Rcpp/String.h index 9825aeb3d..d49f2663d 100644 --- a/inst/include/Rcpp/String.h +++ b/inst/include/Rcpp/String.h @@ -72,11 +72,15 @@ namespace Rcpp { /** construct a string from a single CHARSXP SEXP */ String(SEXP charsxp) : data(charsxp), valid(true), buffer_ready(false), enc(Rf_getCharCE(charsxp)) { - Rcpp_PreserveObject( data ); + if (::Rf_isString(data) && ::Rf_length(data) != 1) + throw ::Rcpp::not_compatible("expecting a single value"); + Rcpp_PreserveObject(data); RCPP_STRING_DEBUG( "String(SEXP)" ) ; } String(SEXP charsxp, const std::string& enc) : data(charsxp), valid(true), buffer_ready(false) { + if (::Rf_isString(data) && ::Rf_length(data) != 1) + throw ::Rcpp::not_compatible("expecting a single value"); Rcpp_PreserveObject( data ); set_encoding(enc); RCPP_STRING_DEBUG( "String(SEXP)" ) ;