summaryrefslogtreecommitdiff
path: root/eval_jump.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-29 04:33:59 +0000
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2014-01-29 04:33:59 +0000
commit1e6eed0cf5a45a787e01630b10d1f3f87e7a01d3 (patch)
treeb75d62bef46d0a3db01bf001dd7b63e3f3fc8fc7 /eval_jump.c
parent888372e5957f4e59b03532bc6fa9e1657b81ecad (diff)
merge revision(s) 43685,43690,43705: [Backport #9110]
* eval_jump.c (rb_exec_end_proc): fix double free or corruption error when reentering by callcc. [ruby-core:58329] [Bug #9110] * test/ruby/test_beginendblock.rb: test for above. * eval_jump.c (rb_exec_end_proc): unlink and free procs data before calling for each procs. [Bug #9110] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@44740 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'eval_jump.c')
-rw-r--r--eval_jump.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/eval_jump.c b/eval_jump.c
index f3a1f78a3f..4f39374a20 100644
--- a/eval_jump.c
+++ b/eval_jump.c
@@ -96,7 +96,8 @@ rb_mark_end_proc(void)
void
rb_exec_end_proc(void)
{
- struct end_proc_data *volatile link;
+ struct end_proc_data volatile endproc;
+ struct end_proc_data volatile *link;
int status;
volatile int safe = rb_safe_level();
rb_thread_t *th = GET_THREAD();
@@ -105,6 +106,9 @@ rb_exec_end_proc(void)
while (ephemeral_end_procs) {
link = ephemeral_end_procs;
ephemeral_end_procs = link->next;
+ endproc = *link;
+ xfree((void *)link);
+ link = &endproc;
PUSH_TAG();
if ((status = EXEC_TAG()) == 0) {
@@ -116,12 +120,14 @@ rb_exec_end_proc(void)
error_handle(status);
if (!NIL_P(th->errinfo)) errinfo = th->errinfo;
}
- xfree(link);
}
while (end_procs) {
link = end_procs;
end_procs = link->next;
+ endproc = *link;
+ xfree((void *)link);
+ link = &endproc;
PUSH_TAG();
if ((status = EXEC_TAG()) == 0) {
@@ -133,8 +139,8 @@ rb_exec_end_proc(void)
error_handle(status);
if (!NIL_P(th->errinfo)) errinfo = th->errinfo;
}
- xfree(link);
}
+
rb_set_safe_level_force(safe);
th->errinfo = errinfo;
}