From 572c674c2b0ac42491f6915d56611ca7ac1cccbf Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sat, 11 Oct 2025 23:01:33 +0900 Subject: [PATCH] mruby-task: fix memory leak in task context cleanup; ref #6641 Co-authored-by: Claude --- mrbgems/mruby-task/src/task.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mrbgems/mruby-task/src/task.c b/mrbgems/mruby-task/src/task.c index 6923374cf..dd86dcda8 100644 --- a/mrbgems/mruby-task/src/task.c +++ b/mrbgems/mruby-task/src/task.c @@ -71,16 +71,15 @@ mrb_task_free(mrb_state *mrb, void *ptr) mrb_gc_unregister(mrb, t->self); } - /* Free context resources only if not already terminated by fiber_terminate */ + /* Free context resources - always free if allocated */ /* Main task never has allocated context (stbase/cibase are NULL) */ - if (t->c.status != MRB_FIBER_TERMINATED) { - if (t->c.stbase) { - mrb_free(mrb, t->c.stbase); - } - if (t->c.cibase) { - mrb_free(mrb, t->c.cibase); - } + if (t->c.stbase) { + mrb_free(mrb, t->c.stbase); } + if (t->c.cibase) { + mrb_free(mrb, t->c.cibase); + } + /* Free the task structure itself */ mrb_free(mrb, t); }