[前][次][番号順一覧][スレッド一覧]

ruby-changes:36344

From: nobu <ko1@a...>
Date: Fri, 14 Nov 2014 17:00:10 +0900 (JST)
Subject: [ruby-changes:36344] nobu:r48425 (trunk): gc.c: check arguments

nobu	2014-11-14 16:59:55 +0900 (Fri, 14 Nov 2014)

  New Revision: 48425

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=revision&revision=48425

  Log:
    gc.c: check arguments
    
    * gc.c (default_proc_for_compat_func): check arguments number and
      type, and get rid of reentering this default proc.

  Modified files:
    trunk/ChangeLog
    trunk/gc.c
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 48424)
+++ ChangeLog	(revision 48425)
@@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1
+Fri Nov 14 16:59:53 2014  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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@a...>
 
 	* gc.c (gc_stat_internal): support comatible layer for
Index: gc.c
===================================================================
--- gc.c	(revision 48424)
+++ gc.c	(revision 48425)
@@ -6477,6 +6477,7 @@ setup_gc_stat_symbols(void) https://github.com/ruby/ruby/blob/trunk/gc.c#L6477
 
 	{
 	    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) https://github.com/ruby/ruby/blob/trunk/gc.c#L6516
 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) https://github.com/ruby/ruby/blob/trunk/gc.c#L6535
 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;

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]