* 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
This commit is contained in:
nobu 2009-05-17 04:15:33 +00:00
parent cda453c238
commit 52b3bf363a
2 changed files with 8 additions and 3 deletions

View File

@ -1,3 +1,7 @@
Sun May 17 13:15:32 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* vm.c (rb_vm_get_sourceline): should not access out of bound.
Sun May 17 09:47:48 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> Sun May 17 09:47:48 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* ruby.c (cmdline_options_init): initialize encodings. * ruby.c (cmdline_options_init): initialize encodings.

7
vm.c
View File

@ -673,10 +673,11 @@ rb_vm_get_sourceline(const rb_control_frame_t *cfp)
if (RUBY_VM_NORMAL_ISEQ_P(iseq)) { if (RUBY_VM_NORMAL_ISEQ_P(iseq)) {
rb_num_t i; 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++) { for (i = 0; i < iseq->insn_info_size; i++) {
if (iseq->insn_info_table[i].position == pos) { if (iseq->insn_info_table[i].position == pos) {
if (i == 0) goto found;
line_no = iseq->insn_info_table[i - 1].line_no; line_no = iseq->insn_info_table[i - 1].line_no;
goto found; goto found;
} }
@ -1462,7 +1463,7 @@ static VALUE *thread_recycle_stack_slot[RECYCLE_MAX];
static int thread_recycle_stack_count = 0; static int thread_recycle_stack_count = 0;
static VALUE * static VALUE *
thread_recycle_stack(int size) thread_recycle_stack(size_t size)
{ {
if (thread_recycle_stack_count) { if (thread_recycle_stack_count) {
return thread_recycle_stack_slot[--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; NODE *newbody;
VALUE klass = cref->nd_clss; VALUE klass = cref->nd_clss;
int noex = cref->nd_visi; int noex = (int)cref->nd_visi;
rb_iseq_t *miseq; rb_iseq_t *miseq;
GetISeqPtr(iseqval, miseq); GetISeqPtr(iseqval, miseq);