proc.c (closure_setup): fix NULL check logic

It used to check ci to be non NULL in line 37, but we silently assumed
ci was not NULL in the `else` clause too. So instead of checking NULL,
we add assertion. This incomplete check was found by clang-tidy.
This commit is contained in:
Yukihiro "Matz" Matsumoto
2024-03-25 23:40:21 +09:00
parent b42b8480d1
commit ef94bfc2e6
+2 -1
View File
@@ -96,7 +96,8 @@ closure_setup(mrb_state *mrb, struct RProc *p)
const struct RProc *up = p->upper;
struct REnv *e = NULL;
if (ci && (e = mrb_vm_ci_env(ci)) != NULL) {
mrb_assert(ci != NULL);
if ((e = mrb_vm_ci_env(ci)) != NULL) {
/* do nothing, because e is assigned already */
}
else if (up) {