From 1b16c560e4941fe1505a92d1cf1c8873134014bb Mon Sep 17 00:00:00 2001 From: akr Date: Sun, 20 Jul 2008 19:57:56 +0000 Subject: [PATCH] * dir.c (dir_initialize): use rb_convert_type instead of rb_check_convert_type to prevent SEGV by Dir.new(".", true). (dir_initialize): use FilePathValue before rb_enc_get(dirname) to prevent SEGV by Dir.new(0). git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@18139 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 7 +++++++ dir.c | 4 ++-- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index a9f9272392..3918ad5b4f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +Mon Jul 21 04:55:20 2008 Tanaka Akira + + * dir.c (dir_initialize): use rb_convert_type instead of + rb_check_convert_type to prevent SEGV by Dir.new(".", true). + (dir_initialize): use FilePathValue before rb_enc_get(dirname) to + prevent SEGV by Dir.new(0). + Mon Jul 21 04:42:15 2008 Tanaka Akira * re.c (rb_reg_s_union): useless rb_enc_get call removed to prevent diff --git a/dir.c b/dir.c index cf278dc4a7..465f97c790 100644 --- a/dir.c +++ b/dir.c @@ -348,7 +348,7 @@ dir_initialize(int argc, VALUE *argv, VALUE dir) if (!NIL_P(opt)) { VALUE v, extenc=Qnil, intenc=Qnil; - opt = rb_check_convert_type(opt, T_HASH, "Hash", "to_hash"); + opt = rb_convert_type(opt, T_HASH, "Hash", "to_hash"); v = rb_hash_aref(opt, sym_intenc); if (!NIL_P(v)) intenc = v; @@ -372,6 +372,7 @@ dir_initialize(int argc, VALUE *argv, VALUE dir) } } + FilePathValue(dirname); { rb_encoding *dirname_encoding = rb_enc_get(dirname); if (rb_usascii_encoding() != dirname_encoding @@ -384,7 +385,6 @@ dir_initialize(int argc, VALUE *argv, VALUE dir) dirname = rb_str_transcode(dirname, rb_enc_from_encoding(extencoding)); } } - FilePathValue(dirname); Data_Get_Struct(dir, struct dir_data, dp); if (dp->dir) closedir(dp->dir);