aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorshugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-17 07:16:14 +0000
committershugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2015-12-17 07:16:14 +0000
commit5f703361393746109d02a5de46a3157408364570 (patch)
tree8495f30e4255f69403c40f3a94f72ac66245b70e
parentc0e58584b89f8b7a9023215da1cafcae37b02155 (diff)
downloadruby-5f703361393746109d02a5de46a3157408364570.tar.gz
* proc.c (rb_block_arity): should not call GetProcPtr() for symbols.
[ruby-core:72205] [Bug #11830] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@53170 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--proc.c13
-rw-r--r--test/ruby/test_symbol.rb7
3 files changed, 21 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 96fc45edfb..c843e2776d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Thu Dec 17 16:13:10 2015 Shugo Maeda <shugo@ruby-lang.org>
+
+ * proc.c (rb_block_arity): should not call GetProcPtr() for symbols.
+ [ruby-core:72205] [Bug #11830]
+
Thu Dec 17 14:16:29 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
* string.c (rb_str_scrub): the result should be infected by the
diff --git a/proc.c b/proc.c
index a43c798a84..b8b2145c41 100644
--- a/proc.c
+++ b/proc.c
@@ -956,10 +956,15 @@ rb_block_arity(void)
min = rb_block_min_max_arity(block, &max);
proc_value = block->proc;
if (proc_value) {
- rb_proc_t *proc;
- GetProcPtr(proc_value, proc);
- if (proc)
- return (proc->is_lambda ? min == max : max != UNLIMITED_ARGUMENTS) ? min : -min-1;
+ if (SYMBOL_P(proc_value)) {
+ return -1;
+ }
+ else {
+ rb_proc_t *proc;
+ GetProcPtr(proc_value, proc);
+ if (proc)
+ return (proc->is_lambda ? min == max : max != UNLIMITED_ARGUMENTS) ? min : -min-1;
+ }
}
return max != UNLIMITED_ARGUMENTS ? min : -min-1;
}
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 0e8417c5ed..94541865f2 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -157,6 +157,13 @@ class TestSymbol < Test::Unit::TestCase
assert_equal(1, first, bug11594)
end
+ def test_to_proc_for_hash_each
+ bug11830 = '[ruby-core:72205] [Bug #11830]'
+ assert_normal_exit(<<-'end;', bug11830) # do
+ {}.each(&:destroy)
+ end;
+ end
+
def test_call
o = Object.new
def o.foo(x, y); x + y; end