summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog10
-rw-r--r--proc.c4
-rw-r--r--test/ruby/test_symbol.rb12
3 files changed, 23 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index fe54268..ca1452a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+Sun Dec 20 00:29:00 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * proc.c (rb_proc_get_iseq): proc made from symbol does not have
+ iseq. fix infinite loop. [ruby-core:72381] [Bug #11845]
+
+Sun Dec 20 00:28:51 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
+
+ * proc.c (rb_proc_get_iseq): proc made from symbol does not have
+ iseq. fix infinite loop. [ruby-core:72381] [Bug #11845]
+
Sat Dec 19 20:06:10 2015 Naohisa Goto <ngotogenome@gmail.com>
* enc/windows_1250.c: Should not use C++ style comments (C99 feature).
diff --git a/proc.c b/proc.c
index 615a6e9..b8c40a1 100644
--- a/proc.c
+++ b/proc.c
@@ -975,7 +975,6 @@ rb_proc_get_iseq(VALUE self, int *is_proc)
const rb_proc_t *proc;
const rb_iseq_t *iseq;
- again:
GetProcPtr(self, proc);
iseq = proc->block.iseq;
if (is_proc) *is_proc = !proc->is_lambda;
@@ -990,8 +989,7 @@ rb_proc_get_iseq(VALUE self, int *is_proc)
return iseq;
}
else if (SYMBOL_P(iseq)) {
- self = rb_sym_to_proc((VALUE)iseq);
- goto again;
+ return NULL;
}
else {
return rb_iseq_check(iseq);
diff --git a/test/ruby/test_symbol.rb b/test/ruby/test_symbol.rb
index 9454186..8960bec 100644
--- a/test/ruby/test_symbol.rb
+++ b/test/ruby/test_symbol.rb
@@ -164,6 +164,18 @@ class TestSymbol < Test::Unit::TestCase
end;
end
+ def test_to_proc_iseq
+ assert_separately([], <<~"end;", timeout: 1) # do
+ bug11845 = '[ruby-core:72381] [Bug #11845]'
+ assert_nil(:class.to_proc.source_location, bug11845)
+ assert_equal([[:rest]], :class.to_proc.parameters, bug11845)
+ c = Class.new {define_method(:klass, :class.to_proc)}
+ m = c.instance_method(:klass)
+ assert_nil(m.source_location, bug11845)
+ assert_equal([[:rest]], m.parameters, bug11845)
+ end;
+ end
+
def test_call
o = Object.new
def o.foo(x, y); x + y; end