mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
8cc0ee4a96
commit
d8d9bac5c8
3 changed files with 17 additions and 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]
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Add table
Reference in a new issue