summaryrefslogtreecommitdiff
path: root/ext/objspace/objspace_dump.c
diff options
context:
space:
mode:
authorJean Boussier <jean.boussier@gmail.com>2021-01-15 18:18:58 +0100
committerAaron Patterson <aaron.patterson@gmail.com>2021-01-20 10:48:13 -0800
commit6ca3d1af3302f722aed530764d07c1cc83e95ecf (patch)
tree36acdd8ddac6d5308ad10fdf16c8de81d422944d /ext/objspace/objspace_dump.c
parent383685b52b086643f7d6e65a4d74fda90d3a64af (diff)
objspace_dump.c: Handle allocation path and line missing
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/4078
Diffstat (limited to 'ext/objspace/objspace_dump.c')
-rw-r--r--ext/objspace/objspace_dump.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c
index 7a5f44aaad..544d11e254 100644
--- a/ext/objspace/objspace_dump.c
+++ b/ext/objspace/objspace_dump.c
@@ -471,10 +471,15 @@ dump_object(VALUE obj, struct dump_config *dc)
dump_append(dc, "]");
if (ainfo) {
- dump_append(dc, ", \"file\":\"");
- dump_append(dc, ainfo->path);
- dump_append(dc, "\", \"line\":");
- dump_append_lu(dc, ainfo->line);
+ if (ainfo->path) {
+ dump_append(dc, ", \"file\":\"");
+ dump_append(dc, ainfo->path);
+ dump_append(dc, "\"");
+ }
+ if (ainfo->line) {
+ dump_append(dc, ", \"line\":");
+ dump_append_lu(dc, ainfo->line);
+ }
if (RTEST(ainfo->mid)) {
VALUE m = rb_sym2str(ainfo->mid);
dump_append(dc, ", \"method\":");