Don't assign the result of mrb_funcall() directly to regs

There are two reasons:

  - If the mruby call stack is extended, the `ci` variable may become invalid.
  - The C language does not specify the order in which the left-hand and right-hand sides of an assignment expression are evaluated.
    Therefore, if the mruby data stack is extended, `ci->stack` may become invalid.
This commit is contained in:
dearblue
2026-03-24 21:25:46 +09:00
parent f61ab96689
commit c52faebb7f
+3 -1
View File
@@ -3112,7 +3112,9 @@ RETRY_TRY_BLOCK:
{ \
mrb_value arg = mrb_int_value(mrb, c); \
mrb_sym mid = MRB_OPSYM(op_name); \
regs[a] = mrb_funcall_argv(mrb, regs[a], mid, 1, &arg); \
mrb_value v = mrb_funcall_argv(mrb, regs[a], mid, 1, &arg); \
ci = mrb->c->ci; \
regs[a] = v; \
mrb_gc_arena_restore(mrb, ai); \
} \
break; \