1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* 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
This commit is contained in:
akr 2008-07-20 19:57:56 +00:00
parent 0f673a177a
commit 1b16c560e4
2 changed files with 9 additions and 2 deletions

View file

@ -1,3 +1,10 @@
Mon Jul 21 04:55:20 2008 Tanaka Akira <akr@fsij.org>
* 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 <akr@fsij.org>
* re.c (rb_reg_s_union): useless rb_enc_get call removed to prevent

4
dir.c
View file

@ -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);