aboutsummaryrefslogtreecommitdiffstats
path: root/ext
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2020-07-09 14:59:59 -0700
committerAaron Patterson <aaron.patterson@gmail.com>2020-08-17 09:47:53 -0700
commit971857c3326b163c45f02922bb5c5143d54e520d (patch)
tree0245113f14e505d3b7a178708068e4bf1d325e9f /ext
parentb52a501ca786a54fdaadf1a60fef517c55dd6ca3 (diff)
downloadruby-971857c3326b163c45f02922bb5c5143d54e520d.tar.gz
Fix method name escaping in ObjectSpace.dump
It's possible to define methods with any name, even if the parser doesn't support it and it can only be used with ex. send. This fixes an issue where invalid JSON was output from ObjectSpace.dump when a method name needed escaping.
Diffstat (limited to 'ext')
-rw-r--r--ext/objspace/objspace_dump.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c
index d5996f67a8..f7b9b0b26c 100644
--- a/ext/objspace/objspace_dump.c
+++ b/ext/objspace/objspace_dump.c
@@ -313,7 +313,8 @@ dump_object(VALUE obj, struct dump_config *dc)
dump_append(dc, ", \"file\":\"%s\", \"line\":%lu", ainfo->path, ainfo->line);
if (RTEST(ainfo->mid)) {
VALUE m = rb_sym2str(ainfo->mid);
- dump_append(dc, ", \"method\":\"%s\"", RSTRING_PTR(m));
+ dump_append(dc, ", \"method\":");
+ dump_append_string_value(dc, m);
}
dump_append(dc, ", \"generation\":%"PRIuSIZE, ainfo->generation);
}