Skip to content

Commit 99ff8c0

Browse files
committed
Merge pull request #376 from RcppCore/bugfix/issue375-string-vector
Bugfix/issue375 string vector
2 parents 94f0e27 + 639c5fd commit 99ff8c0

File tree

4 files changed

+22
-3
lines changed

4 files changed

+22
-3
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2015-09-21 Dirk Eddelbuettel <[email protected]>
2+
3+
* inst/include/Rcpp/String.h: Before assigning ensure we received
4+
exactly one string argument
5+
16
2015-09-10 Dirk Eddelbuettel <[email protected]>
27

38
* DESCRIPTION: Release 0.12.1

DESCRIPTION

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: Rcpp
22
Title: Seamless R and C++ Integration
3-
Version: 0.12.1
4-
Date: 2015-09-10
3+
Version: 0.12.1.1
4+
Date: 2015-09-21
55
Author: Dirk Eddelbuettel, Romain Francois, JJ Allaire, Kevin Ushey,
66
Qiang Kou, Douglas Bates and John Chambers
77
Maintainer: Dirk Eddelbuettel <[email protected]>

inst/NEWS.Rd

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22
\title{News for Package 'Rcpp'}
33
\newcommand{\cpkg}{\href{http://CRAN.R-project.org/package=#1}{\pkg{#1}}}
44

5+
\section{Changes in Rcpp version 0.12.2 (expected 2015-11-01 or later)}{
6+
\itemize{
7+
\item Changes in Rcpp API:
8+
\itemize{
9+
\item Before creating a single String object from a \code{SEXP}, ensure
10+
that it is from a vector of length one (issue #375)
11+
}
12+
}
13+
}
14+
515
\section{Changes in Rcpp version 0.12.1 (2015-09-10)}{
616
\itemize{
717
\item Changes in Rcpp API:

inst/include/Rcpp/String.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,15 @@ namespace Rcpp {
7272

7373
/** construct a string from a single CHARSXP SEXP */
7474
String(SEXP charsxp) : data(charsxp), valid(true), buffer_ready(false), enc(Rf_getCharCE(charsxp)) {
75-
Rcpp_PreserveObject( data );
75+
if (::Rf_isString(data) && ::Rf_length(data) != 1)
76+
throw ::Rcpp::not_compatible("expecting a single value");
77+
Rcpp_PreserveObject(data);
7678
RCPP_STRING_DEBUG( "String(SEXP)" ) ;
7779
}
7880

7981
String(SEXP charsxp, const std::string& enc) : data(charsxp), valid(true), buffer_ready(false) {
82+
if (::Rf_isString(data) && ::Rf_length(data) != 1)
83+
throw ::Rcpp::not_compatible("expecting a single value");
8084
Rcpp_PreserveObject( data );
8185
set_encoding(enc);
8286
RCPP_STRING_DEBUG( "String(SEXP)" ) ;

0 commit comments

Comments
 (0)