Permalink
Browse files

* 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/trunk@33013 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information...
1 parent 4536f22 commit 5cb16a55f56220eb8a0e0bfa69c5427023a12975 @k-tsj k-tsj committed Aug 20, 2011
Showing with 10 additions and 3 deletions.
  1. +6 −0 ChangeLog
  2. +3 −3 iseq.c
  3. +1 −0 test/ruby/test_method.rb
View
@@ -1,3 +1,9 @@
+Sat Aug 20 13:19:52 2011 Kazuki Tsujimoto <kazuki@callcc.net>
+
+ * 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 <nobu@ruby-lang.org>
* ext/stringio/stringio.c (strio_read): return new string if nil
View
6 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) {
View
@@ -123,6 +123,7 @@ def test_body
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

0 comments on commit 5cb16a5

Please sign in to comment.