summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Zhu <peter@peterzhu.ca>2025-09-08 16:26:58 +0200
committerPeter Zhu <peter@peterzhu.ca>2025-09-17 09:25:17 -0400
commit42b6ec0149fbf97d79ddd4d957cecc0fc08f2701 (patch)
treec0a774892ac17026479f98aa0821286381c9aea8
parent74075617b17ab80db74a5e7c1c8515601a8ce6f4 (diff)
Clear memory for newly allocated iseq
-rw-r--r--iseq.h7
1 files changed, 6 insertions, 1 deletions
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);