From 5cbafb8dbeb3e6431c29f532ac468eee4606c9d8 Mon Sep 17 00:00:00 2001 From: John Hawthorn Date: Tue, 5 Dec 2023 13:44:28 -0800 Subject: [PATCH] Use rb_sym2str instead of SYM2ID This avoids pinning an id to the symbol used if a dynamic symbol is passed in as a hash key. rb_sym2str is available in Ruby 2.2+ and json depends on >= 2.3. --- ext/json/ext/generator/generator.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ext/json/ext/generator/generator.c b/ext/json/ext/generator/generator.c index a71acfbb..a33df848 100644 --- a/ext/json/ext/generator/generator.c +++ b/ext/json/ext/generator/generator.c @@ -867,7 +867,7 @@ json_object_i(VALUE key, VALUE val, VALUE _arg) if (klass == rb_cString) { key_to_s = key; } else if (klass == rb_cSymbol) { - key_to_s = rb_id2str(SYM2ID(key)); + key_to_s = rb_sym2str(key); } else { key_to_s = rb_funcall(key, i_to_s, 0); }