summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog6
-rw-r--r--transcode.c40
-rw-r--r--version.h2
3 files changed, 34 insertions, 14 deletions
diff --git a/ChangeLog b/ChangeLog
index 072da3f387..065f58900f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Aug 16 03:10:42 2016 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * transcode.c (enc_arg, str_transcode_enc_args, econv_args):
+ remove volatile, and add GC guards in callers.
+ [ruby-core:75664] [Bug #12411]
+
Tue Aug 16 02:45:52 2016 SHIBATA Hiroshi <hsbt@ruby-lang.org>
* ext/psych/*, test/psych/*: Update psych 2.1.0
diff --git a/transcode.c b/transcode.c
index c2032a897a..0514adaf7e 100644
--- a/transcode.c
+++ b/transcode.c
@@ -2607,7 +2607,7 @@ rb_econv_open_opts(const char *source_encoding, const char *destination_encoding
}
static int
-enc_arg(volatile VALUE *arg, const char **name_p, rb_encoding **enc_p)
+enc_arg(VALUE *arg, const char **name_p, rb_encoding **enc_p)
{
rb_encoding *enc;
const char *n;
@@ -2631,7 +2631,7 @@ enc_arg(volatile VALUE *arg, const char **name_p, rb_encoding **enc_p)
}
static int
-str_transcode_enc_args(VALUE str, volatile VALUE *arg1, volatile VALUE *arg2,
+str_transcode_enc_args(VALUE str, VALUE *arg1, VALUE *arg2,
const char **sname_p, rb_encoding **senc_p,
const char **dname_p, rb_encoding **denc_p)
{
@@ -2662,7 +2662,7 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
{
VALUE dest;
VALUE str = *self;
- volatile VALUE arg1, arg2;
+ VALUE arg1, arg2;
long blen, slen;
unsigned char *buf, *bp, *sp;
const unsigned char *fromp;
@@ -2740,6 +2740,8 @@ str_transcode0(int argc, VALUE *argv, VALUE *self, int ecflags, VALUE ecopts)
/* set encoding */
if (!denc) {
dencidx = rb_define_dummy_encoding(dname);
+ RB_GC_GUARD(arg1);
+ RB_GC_GUARD(arg2);
}
*self = dest;
@@ -2992,7 +2994,7 @@ econv_s_asciicompat_encoding(VALUE klass, VALUE arg)
static void
econv_args(int argc, VALUE *argv,
- volatile VALUE *snamev_p, volatile VALUE *dnamev_p,
+ VALUE *snamev_p, VALUE *dnamev_p,
const char **sname_p, const char **dname_p,
rb_encoding **senc_p, rb_encoding **denc_p,
int *ecflags_p,
@@ -3136,7 +3138,7 @@ search_convpath_i(const char *sname, const char *dname, int depth, void *arg)
static VALUE
econv_s_search_convpath(int argc, VALUE *argv, VALUE klass)
{
- volatile VALUE snamev, dnamev;
+ VALUE snamev, dnamev;
const char *sname, *dname;
rb_encoding *senc, *denc;
int ecflags;
@@ -3151,8 +3153,12 @@ econv_s_search_convpath(int argc, VALUE *argv, VALUE klass)
if (NIL_P(convpath))
rb_exc_raise(rb_econv_open_exc(sname, dname, ecflags));
- if (decorate_convpath(convpath, ecflags) == -1)
- rb_exc_raise(rb_econv_open_exc(sname, dname, ecflags));
+ if (decorate_convpath(convpath, ecflags) == -1) {
+ VALUE exc = rb_econv_open_exc(sname, dname, ecflags);
+ RB_GC_GUARD(snamev);
+ RB_GC_GUARD(dnamev);
+ rb_exc_raise(exc);
+ }
return convpath;
}
@@ -3208,7 +3214,7 @@ rb_econv_init_by_convpath(VALUE self, VALUE convpath,
DATA_PTR(self) = ec;
for (i = 0; i < RARRAY_LEN(convpath); i++) {
- volatile VALUE snamev, dnamev;
+ VALUE snamev, dnamev;
VALUE pair;
elt = rb_ary_entry(convpath, i);
if (!NIL_P(pair = rb_check_array_type(elt))) {
@@ -3225,8 +3231,12 @@ rb_econv_init_by_convpath(VALUE self, VALUE convpath,
}
if (DECORATOR_P(sname, dname)) {
ret = rb_econv_add_converter(ec, sname, dname, ec->num_trans);
- if (ret == -1)
- rb_raise(rb_eArgError, "decoration failed: %s", dname);
+ if (ret == -1) {
+ VALUE msg = rb_sprintf("decoration failed: %s", dname);
+ RB_GC_GUARD(snamev);
+ RB_GC_GUARD(dnamev);
+ rb_exc_raise(rb_exc_new_str(rb_eArgError, msg));
+ }
}
else {
int j = ec->num_trans;
@@ -3235,8 +3245,12 @@ rb_econv_init_by_convpath(VALUE self, VALUE convpath,
arg.index = ec->num_trans;
arg.ret = 0;
ret = transcode_search_path(sname, dname, rb_econv_init_by_convpath_i, &arg);
- if (ret == -1 || arg.ret == -1)
- rb_raise(rb_eArgError, "adding conversion failed: %s to %s", sname, dname);
+ if (ret == -1 || arg.ret == -1) {
+ VALUE msg = rb_sprintf("adding conversion failed: %s to %s", sname, dname);
+ RB_GC_GUARD(snamev);
+ RB_GC_GUARD(dnamev);
+ rb_exc_raise(rb_exc_new_str(rb_eArgError, msg));
+ }
if (first) {
first = 0;
*senc_p = senc;
@@ -3370,7 +3384,7 @@ static VALUE
econv_init(int argc, VALUE *argv, VALUE self)
{
VALUE ecopts;
- volatile VALUE snamev, dnamev;
+ VALUE snamev, dnamev;
const char *sname, *dname;
rb_encoding *senc, *denc;
rb_econv_t *ec;
diff --git a/version.h b/version.h
index 1a07d9e357..80257c1eca 100644
--- a/version.h
+++ b/version.h
@@ -1,6 +1,6 @@
#define RUBY_VERSION "2.3.2"
#define RUBY_RELEASE_DATE "2016-08-16"
-#define RUBY_PATCHLEVEL 153
+#define RUBY_PATCHLEVEL 154
#define RUBY_RELEASE_YEAR 2016
#define RUBY_RELEASE_MONTH 8