diff options
author | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-18 16:04:09 +0000 |
---|---|---|
committer | akr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2008-08-18 16:04:09 +0000 |
commit | 6f02881c9a8a39e38d9d3ceacb3fade89a9bc967 (patch) | |
tree | a9a9192c6d6aacf439cf1c253954025b00482ddb /io.c | |
parent | f6b776a8b55eb97c826cd0fefc16142f469495f4 (diff) | |
download | ruby-6f02881c9a8a39e38d9d3ceacb3fade89a9bc967.tar.gz ruby-6f02881c9a8a39e38d9d3ceacb3fade89a9bc967.tar.xz ruby-6f02881c9a8a39e38d9d3ceacb3fade89a9bc967.zip |
* io.c (rb_open_file): don't access argv[-1] by
File.allocate.instance_eval { initialize }.
git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@18698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r-- | io.c | 18 |
1 files changed, 10 insertions, 8 deletions
@@ -4461,14 +4461,16 @@ rb_open_file(int argc, VALUE *argv, VALUE io) int flags; unsigned int fmode; - opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash"); - if (!NIL_P(opt)) { - VALUE v; - v = rb_hash_aref(opt, sym_mode); - if (!NIL_P(v)) vmode = v; - v = rb_hash_aref(opt, sym_perm); - if (!NIL_P(v)) perm = v; - argc -= 1; + if (0 < argc) { + opt = rb_check_convert_type(argv[argc-1], T_HASH, "Hash", "to_hash"); + if (!NIL_P(opt)) { + VALUE v; + v = rb_hash_aref(opt, sym_mode); + if (!NIL_P(v)) vmode = v; + v = rb_hash_aref(opt, sym_perm); + if (!NIL_P(v)) perm = v; + argc -= 1; + } } rb_scan_args(argc, argv, "12", &fname, &vmode, &perm); |