From 6704a385b7f29617a0d2470cdd77a4e052c1162b Mon Sep 17 00:00:00 2001 From: dearblue Date: Mon, 1 Jun 2026 22:27:59 +0900 Subject: [PATCH] Free the index array immediately at the end of `ary_combination_next()` --- mrbgems/mruby-array-ext/src/array.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mrbgems/mruby-array-ext/src/array.c b/mrbgems/mruby-array-ext/src/array.c index 285ac908a..62a731c36 100644 --- a/mrbgems/mruby-array-ext/src/array.c +++ b/mrbgems/mruby-array-ext/src/array.c @@ -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; }