summaryrefslogtreecommitdiff
path: root/io.c
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-29 13:30:09 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-05-29 13:30:09 +0000
commit17248a467e6af5e1c55c91668c2fe2fae9b6d54d (patch)
treea9d2ea851079c628e6b4b88dd2a3f85f83caaaef /io.c
parent441be3ca066e92f83f5db5fcc6a1ae311ca3d57e (diff)
* io.c (argf_external_encoding, argf_internal_encoding): fix SEGV by
ARGF.external_encoding. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@16680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/io.c b/io.c
index 0b4b4b64b2..e4a0c21c19 100644
--- a/io.c
+++ b/io.c
@@ -6942,13 +6942,19 @@ rb_io_set_encoding(int argc, VALUE *argv, VALUE io)
static VALUE
argf_external_encoding(VALUE argf)
{
- return rb_io_external_encoding(current_file);
+ if (!RTEST(current_file)) {
+ return rb_enc_from_encoding(rb_default_external_encoding());
+ }
+ return rb_io_external_encoding(rb_io_check_io(current_file));
}
static VALUE
argf_internal_encoding(VALUE argf)
{
- return rb_io_internal_encoding(current_file);
+ if (!RTEST(current_file)) {
+ return rb_enc_from_encoding(rb_default_external_encoding());
+ }
+ return rb_io_internal_encoding(rb_io_check_io(current_file));
}
static VALUE