mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
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:
parent
4faf219853
commit
dde690bc32
2 changed files with 7 additions and 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
|
* vm_trace.c (rb_threadptr_exec_event_hooks): fix uninitialized state
|
||||||
when no events is excuted.
|
when no events is excuted.
|
||||||
|
|
18
vm_trace.c
18
vm_trace.c
|
@ -249,31 +249,21 @@ rb_clear_trace_func(void)
|
||||||
static void
|
static void
|
||||||
clean_hooks(rb_hook_list_t *list)
|
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->events = 0;
|
||||||
list->need_clean = 0;
|
list->need_clean = 0;
|
||||||
|
|
||||||
while (hook) {
|
while ((hook = *nextp) != 0) {
|
||||||
if (hook->hook_flags & RUBY_HOOK_FLAG_DELETED) {
|
if (hook->hook_flags & RUBY_HOOK_FLAG_DELETED) {
|
||||||
if (prev == 0) {
|
*nextp = hook->next;
|
||||||
/* start of list */
|
|
||||||
list->hooks = hook->next;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
prev->next = hook->next;
|
|
||||||
}
|
|
||||||
|
|
||||||
recalc_remove_ruby_vm_event_flags(hook->events);
|
recalc_remove_ruby_vm_event_flags(hook->events);
|
||||||
xfree(hook);
|
xfree(hook);
|
||||||
goto next_iter;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
list->events |= hook->events; /* update active events */
|
list->events |= hook->events; /* update active events */
|
||||||
|
nextp = &hook->next;
|
||||||
}
|
}
|
||||||
prev = hook;
|
|
||||||
next_iter:
|
|
||||||
hook = hook->next;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue