summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-24 11:31:21 +0000
committercharliesome <charliesome@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-24 11:31:21 +0000
commitfff358989970b6ac2d4e5971ee98ca1f8a32d639 (patch)
treeff152395587e00b413c7813ee58026a9d6925566
parent8f15f58210e55c08e8c1a2d38c7bf978cdedabc2 (diff)
* compile.c (make_name_for_block): use PRIsVALUE in format string
instead of %s and RSTRING_PTR to protect objects from being garbage collected too soon * encoding.c (str_to_encindex): ditto * hash.c (rb_hash_fetch_m): ditto * io.c (rb_io_reopen): ditto * parse.y (reg_fragment_check_gen): ditto * parse.y (reg_compile_gen): ditto * parse.y (ripper_assert_Qundef): ditto * re.c (rb_reg_raise): ditto * ruby.c (set_option_encoding_once): ditto * vm_eval.c (rb_throw_obj): ditto git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41597 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog15
-rw-r--r--compile.c4
-rw-r--r--encoding.c2
-rw-r--r--hash.c2
-rw-r--r--io.c6
-rw-r--r--parse.y7
-rw-r--r--re.c2
-rw-r--r--ruby.c2
-rw-r--r--vm_eval.c3
9 files changed, 28 insertions, 15 deletions
diff --git a/ChangeLog b/ChangeLog
index 9614435..6c6f8ed 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+Mon Jun 24 20:31:00 2013 Charlie Somerville <charliesome@ruby-lang.org>
+
+ * compile.c (make_name_for_block): use PRIsVALUE in format string
+ instead of %s and RSTRING_PTR to protect objects from being garbage
+ collected too soon
+ * encoding.c (str_to_encindex): ditto
+ * hash.c (rb_hash_fetch_m): ditto
+ * io.c (rb_io_reopen): ditto
+ * parse.y (reg_fragment_check_gen): ditto
+ * parse.y (reg_compile_gen): ditto
+ * parse.y (ripper_assert_Qundef): ditto
+ * re.c (rb_reg_raise): ditto
+ * ruby.c (set_option_encoding_once): ditto
+ * vm_eval.c (rb_throw_obj): ditto
+
Mon Jun 24 07:57:18 2013 Masaya Tarui <tarui@ruby-lang.org>
* gc.c (after_gc_sweep): Have to record malloc info before reset.
diff --git a/compile.c b/compile.c
index ee4dc47..e62eb9c 100644
--- a/compile.c
+++ b/compile.c
@@ -2999,10 +2999,10 @@ make_name_for_block(rb_iseq_t *iseq)
}
if (level == 1) {
- return rb_sprintf("block in %s", RSTRING_PTR(ip->location.label));
+ return rb_sprintf("block in %"PRIsVALUE, ip->location.label);
}
else {
- return rb_sprintf("block (%d levels) in %s", level, RSTRING_PTR(ip->location.label));
+ return rb_sprintf("block (%d levels) in %"PRIsVALUE, level, ip->location.label);
}
}
diff --git a/encoding.c b/encoding.c
index ad7e4bc..1e87501 100644
--- a/encoding.c
+++ b/encoding.c
@@ -179,7 +179,7 @@ str_to_encindex(VALUE enc)
{
int idx = str_find_encindex(enc);
if (idx < 0) {
- rb_raise(rb_eArgError, "unknown encoding name - %s", RSTRING_PTR(enc));
+ rb_raise(rb_eArgError, "unknown encoding name - %"PRIsVALUE, enc);
}
return idx;
}
diff --git a/hash.c b/hash.c
index 65c7741..dcd11d3 100644
--- a/hash.c
+++ b/hash.c
@@ -716,7 +716,7 @@ rb_hash_fetch_m(int argc, VALUE *argv, VALUE hash)
desc = rb_any_to_s(key);
}
desc = rb_str_ellipsize(desc, 65);
- rb_raise(rb_eKeyError, "key not found: %s", RSTRING_PTR(desc));
+ rb_raise(rb_eKeyError, "key not found: %"PRIsVALUE, desc);
}
return if_none;
}
diff --git a/io.c b/io.c
index 650ee14..26299c6 100644
--- a/io.c
+++ b/io.c
@@ -6554,15 +6554,15 @@ rb_io_reopen(int argc, VALUE *argv, VALUE file)
rb_fd_fix_cloexec(fptr->fd);
#ifdef USE_SETVBUF
if (setvbuf(fptr->stdio_file, NULL, _IOFBF, 0) != 0)
- rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fptr->pathv));
+ rb_warn("setvbuf() can't be honoured for %"PRIsVALUE, fptr->pathv);
#endif
if (fptr->stdio_file == stderr) {
if (setvbuf(fptr->stdio_file, NULL, _IONBF, BUFSIZ) != 0)
- rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fptr->pathv));
+ rb_warn("setvbuf() can't be honoured for %"PRIsVALUE, fptr->pathv);
}
else if (fptr->stdio_file == stdout && isatty(fptr->fd)) {
if (setvbuf(fptr->stdio_file, NULL, _IOLBF, BUFSIZ) != 0)
- rb_warn("setvbuf() can't be honoured for %s", RSTRING_PTR(fptr->pathv));
+ rb_warn("setvbuf() can't be honoured for %"PRIsVALUE, fptr->pathv);
}
}
else {
diff --git a/parse.y b/parse.y
index c69556f..fa5609a 100644
--- a/parse.y
+++ b/parse.y
@@ -9740,8 +9740,7 @@ reg_fragment_check_gen(struct parser_params* parser, VALUE str, int options)
err = rb_reg_check_preprocess(str);
if (err != Qnil) {
err = rb_obj_as_string(err);
- compile_error(PARSER_ARG "%s", RSTRING_PTR(err));
- RB_GC_GUARD(err);
+ compile_error(PARSER_ARG "%"PRIsVALUE, err);
return 0;
}
return 1;
@@ -9844,7 +9843,7 @@ reg_compile_gen(struct parser_params* parser, VALUE str, int options)
rb_str_append(rb_str_cat(rb_attr_get(err, mesg), "\n", 1), m);
}
else {
- compile_error(PARSER_ARG "%s", RSTRING_PTR(m));
+ compile_error(PARSER_ARG "%"PRIsVALUE, m);
}
return Qnil;
}
@@ -11400,7 +11399,7 @@ ripper_assert_Qundef(VALUE self, VALUE obj, VALUE msg)
{
StringValue(msg);
if (obj == Qundef) {
- rb_raise(rb_eArgError, "%s", RSTRING_PTR(msg));
+ rb_raise(rb_eArgError, "%"PRIsVALUE, msg);
}
return Qnil;
}
diff --git a/re.c b/re.c
index 487bcc1..4731462 100644
--- a/re.c
+++ b/re.c
@@ -610,7 +610,7 @@ rb_reg_raise(const char *s, long len, const char *err, VALUE re)
{
volatile VALUE desc = rb_reg_desc(s, len, re);
- rb_raise(rb_eRegexpError, "%s: %s", err, RSTRING_PTR(desc));
+ rb_raise(rb_eRegexpError, "%s: %"PRIsVALUE, err, desc);
}
static VALUE
diff --git a/ruby.c b/ruby.c
index 8b46882..2b2e548 100644
--- a/ruby.c
+++ b/ruby.c
@@ -765,7 +765,7 @@ set_option_encoding_once(const char *type, VALUE *name, const char *e, long elen
if (*name &&
rb_funcall(ename, rb_intern("casecmp"), 1, *name) != INT2FIX(0)) {
rb_raise(rb_eRuntimeError,
- "%s already set to %s", type, RSTRING_PTR(*name));
+ "%s already set to %"PRIsVALUE, type, *name);
}
*name = ename;
}
diff --git a/vm_eval.c b/vm_eval.c
index ff6ab2e..91e0d1f 100644
--- a/vm_eval.c
+++ b/vm_eval.c
@@ -1740,8 +1740,7 @@ rb_throw_obj(VALUE tag, VALUE value)
}
if (!tt) {
VALUE desc = rb_inspect(tag);
- RB_GC_GUARD(desc);
- rb_raise(rb_eArgError, "uncaught throw %s", RSTRING_PTR(desc));
+ rb_raise(rb_eArgError, "uncaught throw %"PRIsVALUE, desc);
}
th->errinfo = NEW_THROW_OBJECT(tag, 0, TAG_THROW);