summaryrefslogtreecommitdiffstats
path: root/ext/stringio/stringio.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-08-11 14:29:46 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2005-08-11 14:29:46 +0000
commita8e5a402047b22b89004670a41d50b7e3902e4a7 (patch)
tree925e02ea7b11b1badc349a466bc416460f06b6d0 /ext/stringio/stringio.c
parent90a258c9551610857a46b58e139c19779b67c070 (diff)
downloadruby-a8e5a402047b22b89004670a41d50b7e3902e4a7.tar.gz
ruby-a8e5a402047b22b89004670a41d50b7e3902e4a7.tar.xz
ruby-a8e5a402047b22b89004670a41d50b7e3902e4a7.zip
* ext/stringio/stringio.c: keep holding string after closed.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_8@8968 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'ext/stringio/stringio.c')
-rw-r--r--ext/stringio/stringio.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/ext/stringio/stringio.c b/ext/stringio/stringio.c
index 776e5231b..e26167455 100644
--- a/ext/stringio/stringio.c
+++ b/ext/stringio/stringio.c
@@ -384,10 +384,9 @@ strio_close(self)
VALUE self;
{
struct StringIO *ptr = StringIO(self);
- if (CLOSED(ptr)) {
+ if (CLOSED(ptr) || !(ptr->flags & FMODE_READWRITE)) {
rb_raise(rb_eIOError, "closed stream");
}
- ptr->string = Qnil;
ptr->flags &= ~FMODE_READWRITE;
return Qnil;
}
@@ -407,9 +406,7 @@ strio_close_read(self)
if (!READABLE(ptr)) {
rb_raise(rb_eIOError, "closing non-duplex IO for reading");
}
- if (!((ptr->flags &= ~FMODE_READABLE) & FMODE_READWRITE)) {
- ptr->string = Qnil;
- }
+ ptr->flags &= ~FMODE_READABLE;
return Qnil;
}
@@ -428,9 +425,7 @@ strio_close_write(self)
if (!WRITABLE(ptr)) {
rb_raise(rb_eIOError, "closing non-duplex IO for writing");
}
- if (!((ptr->flags &= ~FMODE_WRITABLE) & FMODE_READWRITE)) {
- ptr->string = Qnil;
- }
+ ptr->flags &= ~FMODE_WRITABLE;
return Qnil;
}