From aef5decf8bceb26b49870b464c8bd61a909d78fb Mon Sep 17 00:00:00 2001 From: ktsj Date: Sat, 20 Aug 2011 04:31:20 +0000 Subject: [PATCH] * backport r33013 from trunk. * iseq.c (iseq_s_disasm): fix a bug that may cause SEGV. * test/ruby/test_method.rb (test_body): add a test for the above change. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@33014 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 8 ++++++++ iseq.c | 6 +++--- test/ruby/test_method.rb | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index ef12ae4b04..93920e7c4a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +Sat Aug 20 13:28:32 2011 Kazuki Tsujimoto + + * backport r33013 from trunk. + + * iseq.c (iseq_s_disasm): fix a bug that may cause SEGV. + + * test/ruby/test_method.rb (test_body): add a test for the above change. + Sat Aug 20 10:43:24 2011 Nobuyoshi Nakada * ext/stringio/stringio.c (strio_read): return new string if nil diff --git a/iseq.c b/iseq.c index c0cf98357f..9737d615c1 100644 --- a/iseq.c +++ b/iseq.c @@ -1030,9 +1030,9 @@ iseq_s_disasm(VALUE klass, VALUE body) rb_proc_t *proc; VALUE iseqval; GetProcPtr(body, proc); - iseqval = proc->block.iseq->self; - if (RUBY_VM_NORMAL_ISEQ_P(iseqval)) { - ret = rb_iseq_disasm(iseqval); + iseq = proc->block.iseq; + if (RUBY_VM_NORMAL_ISEQ_P(iseq)) { + ret = rb_iseq_disasm(iseq->self); } } else if ((iseq = rb_method_get_iseq(body)) != 0) { diff --git a/test/ruby/test_method.rb b/test/ruby/test_method.rb index 1da32791f7..2cc0de5409 100644 --- a/test/ruby/test_method.rb +++ b/test/ruby/test_method.rb @@ -123,6 +123,7 @@ class TestMethod < Test::Unit::TestCase def o.foo; end assert_nothing_raised { RubyVM::InstructionSequence.disasm(o.method(:foo)) } assert_nothing_raised { RubyVM::InstructionSequence.disasm("x".method(:upcase)) } + assert_nothing_raised { RubyVM::InstructionSequence.disasm(method(:to_s).to_proc) } end def test_new