summaryrefslogtreecommitdiff
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
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
-rw-r--r--ChangeLog5
-rw-r--r--gc.c12
2 files changed, 13 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 03b6587612e..bfa03744fb0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Fri Nov 14 16:59:53 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * gc.c (default_proc_for_compat_func): check arguments number and
+ type, and get rid of reentering this default proc.
+
Fri Nov 14 16:33:06 2014 Koichi Sasada <ko1@atdot.net>
* gc.c (gc_stat_internal): support comatible layer for
diff --git a/gc.c b/gc.c
index ef8b3441f72..6c7511cd287 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;