aboutsummaryrefslogtreecommitdiffstats
path: root/eval_jump.c
diff options
context:
space:
mode:
Diffstat (limited to 'eval_jump.c')
-rw-r--r--eval_jump.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/eval_jump.c b/eval_jump.c
index 092ab8766a..fc8a830575 100644
--- a/eval_jump.c
+++ b/eval_jump.c
@@ -97,6 +97,8 @@ void
rb_exec_end_proc(void)
{
struct end_proc_data *volatile link;
+ struct end_proc_data *ephemeral_end_procs_head = ephemeral_end_procs;
+ struct end_proc_data *end_procs_head = end_procs;
int status;
volatile int safe = rb_safe_level();
rb_thread_t *th = GET_THREAD();
@@ -116,7 +118,6 @@ rb_exec_end_proc(void)
error_handle(status);
if (!NIL_P(th->errinfo)) errinfo = th->errinfo;
}
- xfree(link);
}
while (end_procs) {
@@ -133,8 +134,20 @@ rb_exec_end_proc(void)
error_handle(status);
if (!NIL_P(th->errinfo)) errinfo = th->errinfo;
}
+ }
+
+ link = ephemeral_end_procs_head;
+ while (link) {
xfree(link);
+ link = link->next;
}
+
+ link = end_procs_head;
+ while (link) {
+ xfree(link);
+ link = link->next;
+ }
+
rb_set_safe_level_force(safe);
th->errinfo = errinfo;
}