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

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43685 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
glass 2013-11-15 15:29:23 +00:00
parent 549b35c1dc
commit 77a5f5b57b
3 changed files with 34 additions and 2 deletions

View file

@ -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;
}
xfree(link);
}
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;
}