From e72ae8cc0fe471b5426c7babbcf8f7191f3b6d48 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 14 Jan 2012 12:56:46 +0000 Subject: [PATCH] * iseq.c (iseq_data_to_ary): check line info table boundary. line number 0 means no line number info is needed. [ruby-dev:45130] [Bug #5894] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 6 ++++++ iseq.c | 5 +++-- test/ruby/test_iseq.rb | 11 +++++++++++ 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 test/ruby/test_iseq.rb diff --git a/ChangeLog b/ChangeLog index e9d7f705d2..eaf96cf100 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Sat Jan 14 21:56:43 2012 Nobuyoshi Nakada + + * iseq.c (iseq_data_to_ary): check line info table boundary. line + number 0 means no line number info is needed. [ruby-dev:45130] + [Bug #5894] + Sat Jan 14 18:24:13 2012 CHIKANAGA Tomoyuki * error.c (exc_equal): clear rb_thread_t::errinfo when ignore diff --git a/iseq.c b/iseq.c index 3030899d83..fd148dc1a2 100644 --- a/iseq.c +++ b/iseq.c @@ -1104,7 +1104,8 @@ cdhash_each(VALUE key, VALUE value, VALUE ary) static VALUE iseq_data_to_ary(rb_iseq_t *iseq) { - long i, ti; + long i; + size_t ti; unsigned int pos; unsigned int line = 0; VALUE *seq; @@ -1315,7 +1316,7 @@ iseq_data_to_ary(rb_iseq_t *iseq) rb_ary_push(body, (VALUE)label); } - if (iseq->line_info_table[ti].position == pos) { + if (iseq->line_info_size < ti && iseq->line_info_table[ti].position == pos) { line = iseq->line_info_table[ti].line_no; rb_ary_push(body, INT2FIX(line)); ti++; diff --git a/test/ruby/test_iseq.rb b/test/ruby/test_iseq.rb new file mode 100644 index 0000000000..2b25630e57 --- /dev/null +++ b/test/ruby/test_iseq.rb @@ -0,0 +1,11 @@ +require 'test/unit' +require_relative 'envutil' + +class TestISeq < Test::Unit::TestCase + ISeq = RubyVM::InstructionSequence + + def test_no_linenum + bug5894 = '[ruby-dev:45130]' + assert_normal_exit('p RubyVM::InstructionSequence.compile("1", "mac", "", 0).to_a', bug5894) + end +end