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
This commit is contained in:
nobu 2012-08-31 05:03:47 +00:00
Родитель 4faf219853
Коммит dde690bc32
2 изменённых файлов: 7 добавлений и 15 удалений

Просмотреть файл

@ -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.

Просмотреть файл

@ -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;
}
}