summaryrefslogtreecommitdiffstats
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
commit026a67ff9fccfaf19ea6c2e07da75ac78d90ee4b (patch)
treea9d2ea851079c628e6b4b88dd2a3f85f83caaaef /io.c
parent8048bffae1d1b06a06ea6fe7020dbe18409a5015 (diff)
downloadruby-026a67ff9fccfaf19ea6c2e07da75ac78d90ee4b.tar.gz
ruby-026a67ff9fccfaf19ea6c2e07da75ac78d90ee4b.tar.xz
ruby-026a67ff9fccfaf19ea6c2e07da75ac78d90ee4b.zip
* io.c (argf_external_encoding, argf_internal_encoding): fix SEGV by
ARGF.external_encoding. git-svn-id: http://svn.ruby-lang.org/repos/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 0b4b4b64b..e4a0c21c1 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