From f04a729dc93f6f34bc6aec019bdfd820ff32f1a9 Mon Sep 17 00:00:00 2001 From: "Yukihiro \"Matz\" Matsumoto" Date: Sun, 4 Feb 2024 17:06:05 +0900 Subject: [PATCH] gc.c (obj_free): check if irep is NULL before mrb_irep_decref(); #6161 --- src/gc.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gc.c b/src/gc.c index 63d3f1678..a39d4e47f 100644 --- a/src/gc.c +++ b/src/gc.c @@ -827,7 +827,9 @@ obj_free(mrb_state *mrb, struct RBasic *obj, int end) { struct RBacktrace *bt = (struct RBacktrace*)obj; for (size_t i = 0; i < bt->len; i++) { - mrb_irep_decref(mrb, (mrb_irep*)bt->locations[i].irep); + const mrb_irep *irep = bt->locations[i].irep; + if (irep == NULL) continue; + mrb_irep_decref(mrb, (mrb_irep*)irep); } mrb_free(mrb, bt->locations); }