From 52b3bf363ad4f67d79226e2d0e3143d4f85f31c5 Mon Sep 17 00:00:00 2001 From: nobu Date: Sun, 17 May 2009 04:15:33 +0000 Subject: [PATCH] * vm.c (rb_vm_get_sourceline): should not access out of bound. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@23472 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 4 ++++ vm.c | 7 ++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 99940ed9ab..055e64ad69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +Sun May 17 13:15:32 2009 Nobuyoshi Nakada + + * vm.c (rb_vm_get_sourceline): should not access out of bound. + Sun May 17 09:47:48 2009 Nobuyoshi Nakada * ruby.c (cmdline_options_init): initialize encodings. diff --git a/vm.c b/vm.c index 0b05de1a7c..b38bcdf16f 100644 --- a/vm.c +++ b/vm.c @@ -673,10 +673,11 @@ rb_vm_get_sourceline(const rb_control_frame_t *cfp) if (RUBY_VM_NORMAL_ISEQ_P(iseq)) { rb_num_t i; - int pos = cfp->pc - cfp->iseq->iseq_encoded; + size_t pos = cfp->pc - cfp->iseq->iseq_encoded; for (i = 0; i < iseq->insn_info_size; i++) { if (iseq->insn_info_table[i].position == pos) { + if (i == 0) goto found; line_no = iseq->insn_info_table[i - 1].line_no; goto found; } @@ -1462,7 +1463,7 @@ static VALUE *thread_recycle_stack_slot[RECYCLE_MAX]; static int thread_recycle_stack_count = 0; static VALUE * -thread_recycle_stack(int size) +thread_recycle_stack(size_t size) { if (thread_recycle_stack_count) { return thread_recycle_stack_slot[--thread_recycle_stack_count]; @@ -1675,7 +1676,7 @@ vm_define_method(rb_thread_t *th, VALUE obj, ID id, VALUE iseqval, { NODE *newbody; VALUE klass = cref->nd_clss; - int noex = cref->nd_visi; + int noex = (int)cref->nd_visi; rb_iseq_t *miseq; GetISeqPtr(iseqval, miseq);