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

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
This commit is contained in:
nobu 2014-11-14 07:59:55 +00:00
parent a84b2a6afd
commit 7a699d8b0b
2 changed files with 13 additions and 4 deletions

View file

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

12
gc.c
View file

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