summaryrefslogtreecommitdiff
path: root/vm_trace.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-31 05:03:47 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-08-31 05:03:47 +0000
commitdde690bc32f4e7f614bf46edc3f8bce8ad2e131b (patch)
tree8d2f7c016aeb2a933c0bd807dc6c2aad8639aace /vm_trace.c
parent4faf219853a67128c9bd3a1282f0419cd3def0fb (diff)
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
Diffstat (limited to 'vm_trace.c')
-rw-r--r--vm_trace.c18
1 files changed, 4 insertions, 14 deletions
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;
}
}