diff options
author | John Hawthorn <john@hawthorn.email> | 2023-10-11 11:09:04 -0700 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2023-10-12 10:22:32 +0200 |
commit | 635b92099e7ddd1b2eca065134efcfdc7ad7bab3 (patch) | |
tree | 26e6e71bb8a60ec8beb7c8c36d71ec47e1ca9d87 /ext/objspace/objspace_dump.c | |
parent | 9859dbc7fdaef2073fecd062c7294ab4dbb86b27 (diff) |
Fix ObjectSpace.dump with super() callinfo
super() uses 0 as mid for its callinfo, so we need to check for that to
avoid a segfault when using dump_all.
Diffstat (limited to 'ext/objspace/objspace_dump.c')
-rw-r--r-- | ext/objspace/objspace_dump.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index 14d78c862b..50dead5773 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -379,6 +379,7 @@ dump_object(VALUE obj, struct dump_config *dc) rb_io_t *fptr; ID flags[RB_OBJ_GC_FLAGS_MAX]; size_t n, i; + ID mid; if (SPECIAL_CONST_P(obj)) { dump_append_special_const(dc, obj); @@ -433,9 +434,12 @@ dump_object(VALUE obj, struct dump_config *dc) switch (imemo_type(obj)) { case imemo_callinfo: - dump_append(dc, ", \"mid\":\""); - dump_append(dc, RSTRING_PTR(rb_id2str(vm_ci_mid((const struct rb_callinfo *)obj)))); - dump_append(dc, "\""); + mid = vm_ci_mid((const struct rb_callinfo *)obj); + if (mid != 0) { + dump_append(dc, ", \"mid\":\""); + dump_append(dc, rb_id2name(mid)); + dump_append(dc, "\""); + } break; default: |