From dde690bc32f4e7f614bf46edc3f8bce8ad2e131b Mon Sep 17 00:00:00 2001 From: nobu Date: Fri, 31 Aug 2012 05:03:47 +0000 Subject: vm_trace.c: freed memory access * vm_trace.c (clean_hooks): do not access freed memory. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36862 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- vm_trace.c | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'vm_trace.c') 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; } } -- cgit v1.2.3