diff options
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | vm.c | 20 | ||||
-rw-r--r-- | vm_eval.c | 4 |
3 files changed, 22 insertions, 10 deletions
@@ -1,3 +1,11 @@ +Sat May 26 17:05:45 2012 Koichi Sasada <ko1@atdot.net> + + * vm.c (backtrace_*): change type of lev and n from size_t to int. + Also set type of rb_backtrace_t#backtrace_size to int. + A patch from nobu. + + * vm_eval.c: ditto. + Sat May 26 16:26:30 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> * file.c (realpath_rec): UNC prefix does not end with path separator, @@ -1026,7 +1026,7 @@ frame_info_to_str_m(VALUE self) typedef struct rb_backtrace_struct { rb_frame_info_t *backtrace; rb_frame_info_t *backtrace_base; - size_t backtrace_size; + int backtrace_size; VALUE strary; } rb_backtrace_t; @@ -1198,9 +1198,13 @@ backtreace_collect(rb_backtrace_t *bt, int lev, int n, VALUE (*func)(rb_frame_in VALUE btary; int i; + if (UNLIKELY(lev < 0 || n < 0)) { + rb_bug("backtreace_collect: unreachable"); + } + btary = rb_ary_new(); - for (i=0; i+lev<(int)bt->backtrace_size && i<n; i++) { + for (i=0; i+lev<bt->backtrace_size && i<n; i++) { rb_frame_info_t *fi = &bt->backtrace[bt->backtrace_size - 1 - (lev+i)]; rb_ary_push(btary, func(fi, arg)); } @@ -1230,10 +1234,10 @@ rb_backtrace_to_str_ary(VALUE self) } static VALUE -backtrace_to_str_ary2(VALUE self, size_t lev, size_t n) +backtrace_to_str_ary2(VALUE self, int lev, int n) { rb_backtrace_t *bt; - size_t size; + int size; GetCoreDataFromValue(self, rb_backtrace_t, bt); size = bt->backtrace_size; @@ -1261,10 +1265,10 @@ frame_info_create(rb_frame_info_t *srcfi, void *btobj) } static VALUE -backtrace_to_frame_ary(VALUE self, size_t lev, size_t n) +backtrace_to_frame_ary(VALUE self, int lev, int n) { rb_backtrace_t *bt; - size_t size; + int size; GetCoreDataFromValue(self, rb_backtrace_t, bt); size = bt->backtrace_size; @@ -1295,13 +1299,13 @@ backtrace_load_data(VALUE self, VALUE str) } static VALUE -vm_backtrace_str_ary(rb_thread_t *th, size_t lev, size_t n) +vm_backtrace_str_ary(rb_thread_t *th, int lev, int n) { return backtrace_to_str_ary2(backtrace_object(th), lev, n); } static VALUE -vm_backtrace_frame_ary(rb_thread_t *th, size_t lev, size_t n) +vm_backtrace_frame_ary(rb_thread_t *th, int lev, int n) { return backtrace_to_frame_ary(backtrace_object(th), lev, n); } @@ -20,8 +20,8 @@ static VALUE vm_exec(rb_thread_t *th); static void vm_set_eval_stack(rb_thread_t * th, VALUE iseqval, const NODE *cref); static int vm_collect_local_variables_in_heap(rb_thread_t *th, VALUE *dfp, VALUE ary); -static VALUE vm_backtrace_str_ary(rb_thread_t *th, size_t lev, size_t n); -static VALUE vm_backtrace_frame_ary(rb_thread_t *th, size_t lev, size_t n); +static VALUE vm_backtrace_str_ary(rb_thread_t *th, int lev, int n); +static VALUE vm_backtrace_frame_ary(rb_thread_t *th, int lev, int n); static void vm_backtrace_print(FILE *fp); typedef enum call_type { |