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

ruby-changes:46045

From: usa <ko1@a...>
Date: Sun, 26 Mar 2017 03:13:24 +0900 (JST)
Subject: [ruby-changes:46045] usa:r58116 (ruby_2_2): merge revision(s) 57024: [Backport #13015]

usa	2017-03-26 03:13:17 +0900 (Sun, 26 Mar 2017)

  New Revision: 58116

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

  Log:
    merge revision(s) 57024: [Backport #13015]
    
    vm.c: check type of hash to merge
    
    * vm.c (core_hash_merge): check the type of the target hash to
      merge.  [ruby-core:78536] [Bug #13015]

  Modified directories:
    branches/ruby_2_2/
  Modified files:
    branches/ruby_2_2/test/ruby/test_keyword.rb
    branches/ruby_2_2/version.h
    branches/ruby_2_2/vm.c
Index: ruby_2_2/version.h
===================================================================
--- ruby_2_2/version.h	(revision 58115)
+++ ruby_2_2/version.h	(revision 58116)
@@ -1,6 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/ruby_2_2/version.h#L1
 #define RUBY_VERSION "2.2.7"
 #define RUBY_RELEASE_DATE "2017-03-26"
-#define RUBY_PATCHLEVEL 448
+#define RUBY_PATCHLEVEL 449
 
 #define RUBY_RELEASE_YEAR 2017
 #define RUBY_RELEASE_MONTH 3
Index: ruby_2_2/vm.c
===================================================================
--- ruby_2_2/vm.c	(revision 58115)
+++ ruby_2_2/vm.c	(revision 58116)
@@ -2345,6 +2345,7 @@ core_hash_merge(VALUE hash, long argc, c https://github.com/ruby/ruby/blob/trunk/ruby_2_2/vm.c#L2345
 {
     long i;
 
+    Check_Type(hash, T_HASH);
     assert(argc % 2 == 0);
     for (i=0; i<argc; i+=2) {
 	rb_hash_aset(hash, argv[i], argv[i+1]);
@@ -2366,7 +2367,7 @@ core_hash_from_ary(VALUE ary) https://github.com/ruby/ruby/blob/trunk/ruby_2_2/vm.c#L2367
     VALUE hash = rb_hash_new();
 
     if (RUBY_DTRACE_HASH_CREATE_ENABLED()) {
-	RUBY_DTRACE_HASH_CREATE(RARRAY_LEN(ary), rb_sourcefile(), rb_sourceline());
+	RUBY_DTRACE_HASH_CREATE((Check_Type(ary, T_ARRAY), RARRAY_LEN(ary)), rb_sourcefile(), rb_sourceline());
     }
 
     return core_hash_merge_ary(hash, ary);
@@ -2382,6 +2383,7 @@ m_core_hash_merge_ary(VALUE self, VALUE https://github.com/ruby/ruby/blob/trunk/ruby_2_2/vm.c#L2383
 static VALUE
 core_hash_merge_ary(VALUE hash, VALUE ary)
 {
+    Check_Type(ary, T_ARRAY);
     core_hash_merge(hash, RARRAY_LEN(ary), RARRAY_CONST_PTR(ary));
     return hash;
 }
Index: ruby_2_2/test/ruby/test_keyword.rb
===================================================================
--- ruby_2_2/test/ruby/test_keyword.rb	(revision 58115)
+++ ruby_2_2/test/ruby/test_keyword.rb	(revision 58116)
@@ -615,4 +615,24 @@ class TestKeywordArguments < Test::Unit: https://github.com/ruby/ruby/blob/trunk/ruby_2_2/test/ruby/test_keyword.rb#L615
     assert_equal(x, result)
     assert_kind_of(klass, result, bug12884)
   end
+
+  def test_kwrest_overwritten
+    bug13015 = '[ruby-core:78536] [Bug #13015]'
+
+    klass = EnvUtil.labeled_class("Parent") do
+      def initialize(d:)
+      end
+    end
+
+    klass = EnvUtil.labeled_class("Child", klass) do
+      def initialize(d:, **h)
+        h = [2, 3]
+        super
+      end
+    end
+
+    assert_raise_with_message(TypeError, /expected Hash/, bug13015) do
+      klass.new(d: 4)
+    end
+  end
 end

Property changes on: ruby_2_2
___________________________________________________________________
Modified: svn:mergeinfo
   Merged /trunk:r57024


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

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