diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-05 20:14:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2011-01-05 20:14:43 +0000 |
commit | d8d9bac5c8b071135e50ad3f21c8a9b6a9c06e54 (patch) | |
tree | b6b957bc5a752f891d43881e303ec395d639f3db | |
parent | 8cc0ee4a967af26feb0f1d723c5178cafd434ce8 (diff) | |
download | ruby-d8d9bac5c8b071135e50ad3f21c8a9b6a9c06e54.tar.gz |
* ext/stringio/stringio.c (get_strio, strio_set_string)
(strio_reopen): check if frozen. [ruby-core:33648]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@30467 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ext/stringio/stringio.c | 6 | ||||
-rw-r--r-- | test/stringio/test_stringio.rb | 9 |
3 files changed, 17 insertions, 3 deletions
@@ -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 |