Move NULL check to `mrb_env_unshare()`; ref
@@ -279,6 +279,8 @@ cipush(mrb_state *mrb)
MRB_API void
mrb_env_unshare(mrb_state *mrb, struct REnv *e)
{
+ if (e == NULL) return;
+ else {
size_t len = (size_t)MRB_ENV_STACK_LEN(e);
ptrdiff_t cioff = e->cioff;
mrb_value *p;
@@ -299,6 +301,7 @@ mrb_env_unshare(mrb_state *mrb, struct REnv *e)
e->stack = p;
mrb_write_barrier(mrb, (struct RBasic *)e);
}
+}
static inline void
cipop(mrb_state *mrb)
@@ -307,11 +310,8 @@ cipop(mrb_state *mrb)
struct REnv *env = c->ci->env;
c->ci--;
-
- if (env) {
mrb_env_unshare(mrb, env);
}
-}
void mrb_exc_set(mrb_state *mrb, mrb_value exc);
@@ -1960,16 +1960,15 @@ RETRY_TRY_BLOCK:
}
ce = mrb->c->cibase + e->cioff;
- while (ci >= ce) {
- if (ci->env) {
+ while (ci > ce) {
mrb_env_unshare(mrb, ci->env);
- }
- if (ci != ce && ci->acc < 0) {
+ if (ci->acc < 0) {
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
goto L_RAISE;
}
ci--;
}
+ mrb_env_unshare(mrb, ci->env);
if (ce == mrb->c->cibase) {
localjump_error(mrb, LOCALJUMP_ERROR_RETURN);
goto L_RAISE;
@@ -2045,9 +2044,7 @@ RETRY_TRY_BLOCK:
mrb->c->stack = ci->stackent;
mrb->c->ci = mrb->c->cibase + proc->env->cioff + 1;
while (ci > mrb->c->ci) {
- if (ci->env) {
mrb_env_unshare(mrb, ci->env);
- }
if (ci[-1].acc == CI_ACC_SKIP) {
mrb->c->ci = ci;
goto L_BREAK_ERROR;
