summaryrefslogtreecommitdiff
path: root/gc.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-14 07:59:55 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-11-14 07:59:55 +0000
commit7a699d8b0b54997641485b2fb37f1b3deff9d101 (patch)
tree794215a0db8d9891a7b67d5699cbcca20b4a0eed /gc.c
parenta84b2a6afd1557829cd30843e0bee27e960adbe8 (diff)
gc.c: check arguments
* gc.c (default_proc_for_compat_func): check arguments number and type, and get rid of reentering this default proc. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48425 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'gc.c')
-rw-r--r--gc.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/gc.c b/gc.c
index ef8b3441f7..6c7511cd28 100644
--- a/gc.c
+++ b/gc.c
@@ -6477,6 +6477,7 @@ setup_gc_stat_symbols(void)
{
VALUE table = gc_stat_compat_table = rb_hash_new();
+ rb_obj_hide(table);
rb_gc_register_mark_object(table);
/* compatibility layer for Ruby 2.1 */
@@ -6515,7 +6516,7 @@ setup_gc_stat_symbols(void)
static VALUE
compat_key(VALUE key)
{
- VALUE new_key = rb_hash_aref(gc_stat_compat_table, key);
+ VALUE new_key = rb_hash_lookup(gc_stat_compat_table, key);
if (!NIL_P(new_key)) {
static int warned = 0;
@@ -6534,11 +6535,14 @@ compat_key(VALUE key)
static VALUE
default_proc_for_compat_func(VALUE hash, VALUE dmy, int argc, VALUE *argv)
{
- VALUE key = argv[1];
- VALUE new_key = Qnil;
+ VALUE key, new_key;
+
+ Check_Type(hash, T_HASH);
+ rb_check_arity(argc, 2, 2);
+ key = argv[1];
if ((new_key = compat_key(key)) != Qnil) {
- return rb_hash_aref(hash, new_key);
+ return rb_hash_lookup(hash, new_key);
}
return Qnil;