diff options
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | vm_trace.c | 18 |
2 files changed, 7 insertions, 15 deletions
@@ -1,4 +1,6 @@ -Fri Aug 31 14:02:44 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> +Fri Aug 31 14:03:45 2012 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * vm_trace.c (clean_hooks): do not access freed memory. * vm_trace.c (rb_threadptr_exec_event_hooks): fix uninitialized state when no events is excuted. diff --git a/vm_trace.c b/vm_trace.c index df07be6c9b..349063e1ec 100644 --- a/vm_trace.c +++ b/vm_trace.c @@ -249,31 +249,21 @@ rb_clear_trace_func(void) static void clean_hooks(rb_hook_list_t *list) { - rb_event_hook_t *hook = list->hooks, *prev = 0; + rb_event_hook_t *hook, **nextp = &list->hooks; list->events = 0; list->need_clean = 0; - while (hook) { + while ((hook = *nextp) != 0) { if (hook->hook_flags & RUBY_HOOK_FLAG_DELETED) { - if (prev == 0) { - /* start of list */ - list->hooks = hook->next; - } - else { - prev->next = hook->next; - } - + *nextp = hook->next; recalc_remove_ruby_vm_event_flags(hook->events); xfree(hook); - goto next_iter; } else { list->events |= hook->events; /* update active events */ + nextp = &hook->next; } - prev = hook; - next_iter: - hook = hook->next; } } |