From 42b6ec0149fbf97d79ddd4d957cecc0fc08f2701 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Mon, 8 Sep 2025 16:26:58 +0200 Subject: Clear memory for newly allocated iseq --- iseq.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/iseq.h b/iseq.h index 1cecc6960d..c7f091a0b4 100644 --- a/iseq.h +++ b/iseq.h @@ -175,7 +175,12 @@ ISEQ_COMPILE_DATA_CLEAR(rb_iseq_t *iseq) static inline rb_iseq_t * iseq_imemo_alloc(void) { - return IMEMO_NEW(rb_iseq_t, imemo_iseq, 0); + rb_iseq_t *iseq = IMEMO_NEW(rb_iseq_t, imemo_iseq, 0); + + // Clear out the whole iseq except for the flags. + memset((char *)iseq + sizeof(VALUE), 0, sizeof(rb_iseq_t) - sizeof(VALUE)); + + return iseq; } VALUE rb_iseq_ibf_dump(const rb_iseq_t *iseq, VALUE opt); -- cgit v1.2.3