Call stack may not reference the destination proc; fix #3838

The destination `proc` may be an orphan.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2017-10-31 08:58:17 +09:00
parent b6598e052f
commit 022570ab8d
+3 -2
View File
@@ -1916,6 +1916,7 @@ RETRY_TRY_BLOCK:
case OP_R_RETURN:
/* Fall through to OP_R_NORMAL otherwise */
if (ci->acc >=0 && MRB_PROC_ENV_P(proc) && !MRB_PROC_STRICT_P(proc)) {
mrb_callinfo *cibase = mrb->c->cibase;
dst = top_proc(mrb, proc);
if (MRB_PROC_ENV_P(dst)) {
@@ -1926,14 +1927,14 @@ RETRY_TRY_BLOCK:
goto L_RAISE;
}
}
while (ci->proc != dst) {
while (cibase <= ci && ci->proc != dst) {
if (ci->acc < 0) {
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
goto L_RAISE;
}
ci--;
}
if (ci == mrb->c->cibase) {
if (ci <= cibase) {
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
goto L_RAISE;
}