Free the index array immediately at the end of ary_combination_next()

This commit is contained in:
dearblue
2026-06-01 22:27:59 +09:00
parent 72e5ebed55
commit 6704a385b7
+4
View File
@@ -1636,6 +1636,8 @@ ary_combination_next(mrb_state *mrb, mrb_value self)
for (mrb_int i = 0; i < state->k; i++) {
if (state->indices[i] >= state->n) {
state->mode = comb_finished;
mrb_free(mrb, state->indices);
state->indices = NULL;
return mrb_nil_value();
}
}
@@ -1698,6 +1700,8 @@ ary_combination_next(mrb_state *mrb, mrb_value self)
}
state->mode = comb_finished;
mrb_free(mrb, state->indices);
state->indices = NULL;
return result;
}