summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-22 13:46:12 +0000
committernagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2017-03-22 13:46:12 +0000
commit4e1f1ec1a869e8b417b7f638ac4b62945b422b61 (patch)
treee922e66662f97b9f390eeb784b60238b3f33e378
parente120cc91f0fedc876e23259ecdb9fb65c71e57dd (diff)
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] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_3@58056 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--test/ruby/test_keyword.rb20
-rw-r--r--version.h6
-rw-r--r--vm.c4
3 files changed, 26 insertions, 4 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb
index 6c38ff472e..ef9e71e0b2 100644
--- a/test/ruby/test_keyword.rb
+++ b/test/ruby/test_keyword.rb
@@ -604,4 +604,24 @@ class TestKeywordArguments < Test::Unit::TestCase
assert_equal({x: 1, y: 2, **h}, obj.foo)
}
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
diff --git a/version.h b/version.h
index ca57527801..385e0790eb 100644
--- a/version.h
+++ b/version.h
@@ -1,10 +1,10 @@
#define RUBY_VERSION "2.3.3"
-#define RUBY_RELEASE_DATE "2017-03-20"
-#define RUBY_PATCHLEVEL 255
+#define RUBY_RELEASE_DATE "2017-03-22"
+#define RUBY_PATCHLEVEL 256
#define RUBY_RELEASE_YEAR 2017
#define RUBY_RELEASE_MONTH 3
-#define RUBY_RELEASE_DAY 20
+#define RUBY_RELEASE_DAY 22
#include "ruby/version.h"
diff --git a/vm.c b/vm.c
index c3d3e5e5f1..728917d753 100644
--- a/vm.c
+++ b/vm.c
@@ -2529,6 +2529,7 @@ core_hash_merge(VALUE hash, long argc, const VALUE *argv)
{
long i;
+ Check_Type(hash, T_HASH);
VM_ASSERT(argc % 2 == 0);
for (i=0; i<argc; i+=2) {
rb_hash_aset(hash, argv[i], argv[i+1]);
@@ -2549,7 +2550,7 @@ core_hash_from_ary(VALUE ary)
{
VALUE hash = rb_hash_new();
- RUBY_DTRACE_CREATE_HOOK(HASH, RARRAY_LEN(ary));
+ RUBY_DTRACE_CREATE_HOOK(HASH, (Check_Type(ary, T_ARRAY), RARRAY_LEN(ary)));
return core_hash_merge_ary(hash, ary);
}
@@ -2563,6 +2564,7 @@ m_core_hash_merge_ary(VALUE self, VALUE hash, VALUE ary)
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;
}