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

ruby-changes:40415

From: nobu <ko1@a...>
Date: Sun, 8 Nov 2015 17:33:08 +0900 (JST)
Subject: [ruby-changes:40415] nobu:r52496 (trunk): hash.c: fix oob access

nobu	2015-11-08 17:32:51 +0900 (Sun, 08 Nov 2015)

  New Revision: 52496

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

  Log:
    hash.c: fix oob access
    
    * hash.c (rb_hash_default): do not access argv when no arguments
      is given.

  Modified files:
    trunk/hash.c
Index: hash.c
===================================================================
--- hash.c	(revision 52495)
+++ hash.c	(revision 52496)
@@ -902,14 +902,15 @@ rb_hash_fetch(VALUE hash, VALUE key) https://github.com/ruby/ruby/blob/trunk/hash.c#L902
 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;
 }

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

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