Merge pull request #6877 from dearblue/array-ext

Free the index array immediately at the end of `ary_combination_next()`
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-06-02 07:07:56 +09:00
committed by GitHub
+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;
}