Skip to content

Commit

Permalink
Use rb_sym2str instead of SYM2ID
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
jhawthorn committed Dec 5, 2023
1 parent a1af7a3 commit 5cbafb8
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion ext/json/ext/generator/generator.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 5cbafb8

Please sign in to comment.