aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--ext/stringio/stringio.c6
-rw-r--r--test/stringio/test_stringio.rb9
3 files changed, 17 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 51646c1857..2a629260e0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Jan 6 05:14:41 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * ext/stringio/stringio.c (get_strio, strio_set_string)
+ (strio_reopen): check if frozen. [ruby-core:33648]
+
Thu Jan 6 05:10:58 2011 Nobuyoshi Nakada <nobu@ruby-lang.org>
* array.c (rb_ary_resize): new utility function. [ruby-dev:42912]
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 7edf7119e3..208fd4d76e 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -85,7 +85,7 @@ static const rb_data_type_t strio_data_type = {
static struct StringIO*
get_strio(VALUE self)
{
- struct StringIO *ptr = check_strio(self);
+ struct StringIO *ptr = check_strio(rb_io_taint_check(self));
if (!ptr) {
rb_raise(rb_eIOError, "uninitialized stream");
@@ -312,7 +312,7 @@ strio_set_string(VALUE self, VALUE string)
{
struct StringIO *ptr = StringIO(self);
- if (!OBJ_TAINTED(self)) rb_secure(4);
+ rb_io_taint_check(self);
ptr->flags &= ~FMODE_READWRITE;
StringValue(string);
ptr->flags = OBJ_FROZEN(string) ? FMODE_READABLE : FMODE_READWRITE;
@@ -504,7 +504,7 @@ strio_set_lineno(VALUE self, VALUE lineno)
static VALUE
strio_reopen(int argc, VALUE *argv, VALUE self)
{
- if (!OBJ_TAINTED(self)) rb_secure(4);
+ rb_io_taint_check(self);
if (argc == 1 && TYPE(*argv) != T_STRING) {
return strio_copy(self, *argv);
}
diff --git a/test/stringio/test_stringio.rb b/test/stringio/test_stringio.rb
index b7327adced..78718a2d86 100644
--- a/test/stringio/test_stringio.rb
+++ b/test/stringio/test_stringio.rb
@@ -471,4 +471,13 @@ class TestStringIO < Test::Unit::TestCase
expected_pos += 1
end
end
+
+ def test_frozen
+ s = StringIO.new
+ s.freeze
+ bug = '[ruby-core:33648]'
+ assert_raise(RuntimeError, bug) {s.puts("foo")}
+ assert_raise(RuntimeError, bug) {s.string = "foo"}
+ assert_raise(RuntimeError, bug) {s.reopen("")}
+ end
end