Skip to content

Commit

Permalink
* iseq.c (iseq_data_to_ary): check line info table boundary. line
Browse files Browse the repository at this point in the history
  number 0 means no line number info is needed.  [ruby-dev:45130]
  [Bug ruby#5894]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34303 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
  • Loading branch information
nobu committed Jan 14, 2012
1 parent 3772335 commit e72ae8c
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
Sat Jan 14 21:56:43 2012 Nobuyoshi Nakada <[email protected]>

* 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 <[email protected]>

* error.c (exc_equal): clear rb_thread_t::errinfo when ignore
Expand Down
5 changes: 3 additions & 2 deletions iseq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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++;
Expand Down
11 changes: 11 additions & 0 deletions test/ruby/test_iseq.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit e72ae8c

Please sign in to comment.