summaryrefslogtreecommitdiff
path: root/hash.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-08 08:32:51 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-11-08 08:32:51 +0000
commit12c244d347b6620ea14e06c9f60c164dce7427ef (patch)
tree4a09a5f5c6718c2ef2bd4808af94d17213b231e7 /hash.c
parent18034276608ec2c61198e7e38065997d47cf3725 (diff)
hash.c: fix oob access
* hash.c (rb_hash_default): do not access argv when no arguments is given. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52496 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'hash.c')
-rw-r--r--hash.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/hash.c b/hash.c
index 974ac53888..c179ff4ce1 100644
--- a/hash.c
+++ b/hash.c
@@ -902,14 +902,15 @@ rb_hash_fetch(VALUE hash, VALUE key)
static VALUE
rb_hash_default(int argc, VALUE *argv, VALUE hash)
{
- VALUE key, ifnone;
+ VALUE args[2], ifnone;
rb_check_arity(argc, 0, 1);
- key = argv[0];
ifnone = RHASH_IFNONE(hash);
if (FL_TEST(hash, HASH_PROC_DEFAULT)) {
if (argc == 0) return Qnil;
- return rb_funcall(ifnone, id_yield, 2, hash, key);
+ args[0] = hash;
+ args[1] = argv[0];
+ return rb_funcallv(ifnone, id_yield, 2, args);
}
return ifnone;
}