summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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 961443523a..6c6f8edf48 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 ee4dc47e59..e62eb9cbbb 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 ad7e4bcc14..1e875018e4 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 65c7741262..dcd11d3cfe 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 650ee14cae..26299c6c14 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 c69556f70e..fa5609a649 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 487bcc1668..4731462d88 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 8b4688254d..2b2e548de8 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 ff6ab2e2ed..91e0d1fb5d 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);